Skip to content

Automate browser based workflows with AI

449 B
Raw Blame
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,
}));