mirror of
https://github.com/docmost/docmost.git
synced 2025-11-18 06:21:10 +10:00
15 lines
483 B
TypeScript
15 lines
483 B
TypeScript
import Cookies from "js-cookie";
|
|
import { createJSONStorage, atomWithStorage } from "jotai/utils";
|
|
import { ITokens } from "@/features/auth/types/auth.types";
|
|
|
|
|
|
const cookieStorage = createJSONStorage<ITokens>(() => {
|
|
return {
|
|
getItem: () => Cookies.get("authTokens"),
|
|
setItem: (key, value) => Cookies.set(key, value),
|
|
removeItem: (key) => Cookies.remove(key),
|
|
};
|
|
});
|
|
|
|
export const authTokensAtom = atomWithStorage<ITokens | null>("authTokens", null, cookieStorage);
|