Files
Dorod-Sky/skyvern-frontend/src/store/useClientIdStore.ts
2025-06-30 16:35:31 +00:00

22 lines
449 B
TypeScript

import { create } from "zustand";
import { nanoid } from "nanoid";
type ClientIdStore = {
clientId: string;
};
const generateClientId = (): string => {
try {
return crypto.randomUUID();
} catch (error) {
// if crypto.randomUUID() fails, use nanoid as a fallback
return nanoid();
}
};
const initialClientId = generateClientId();
export const useClientIdStore = create<ClientIdStore>(() => ({
clientId: initialClientId,
}));