25 lines
409 B
TypeScript
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;
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|