UNPKG

supakit

Version:

A Supabase auth helper for SvelteKit. Relies on browser cookies.

11 lines (10 loc) 375 B
import { setContext, getContext, hasContext } from 'svelte'; import { writable } from 'svelte/store'; const keys = { session: Symbol() }; const initSession = () => { setContext(keys.session, writable()); return getContext(keys.session); }; export const getSession = () => { return hasContext(keys.session) ? getContext(keys.session) : initSession(); };