Files
pwa/src/atoms/auth.ts
T
2025-11-18 20:22:25 +03:30

25 lines
409 B
TypeScript

import { atom } from 'jotai';
import type { User, Session } from '@supabase/supabase-js';
export const sessionAtom = atom<Session | null>(null);
export const userAtom = atom<User | null>((get) => {
const session = get(sessionAtom);
return session?.user ?? null;
});
export const isAuthenticatedAtom = atom<boolean>((get) => {
const session = get(sessionAtom);
return !!session?.user;
});