Loading…
Loading…
Synchronous localStorage-backed session provider for the browser credential-storage flavor
The browser / sync session flavor, used when credentialStorageType: "browser". The session initializes synchronously on the client from localStorage, so there is no Suspense ready gate — consumers read readiness off the store's fetching flag instead. Mirrors AsyncSessionProvider but drives its store with useSessionManager (a synchronous TokenManagerInterface) rather than useAsyncSessionManager.
Exported from the client entry point, @woographql/next.
import { SessionProvider, createSyncSessionContext } from '@woographql/next';
| Export | Signature | Description |
|---|---|---|
SessionProvider | <T>(props) => JSX.Element | Client provider component. Props: context, operations, tokenManager (sync), revalidateKey, optional initialState + config. |
createSyncSessionContext | <SD, TM>(initialState?: Partial<SD>) => { context, useSession, useCartMutations, … } | Synchronous counterpart to createSessionContext — useSession reads context directly and never suspends; readiness is surfaced through the store's fetching flag. |
'use client'; import { SessionProvider, createSyncSessionContext } from '@woographql/next'; const { context, useSession } = createSyncSessionContext(); export function Providers({ children, tokenManager, operations, revalidateKey }) { return ( <SessionProvider context={context} operations={operations} tokenManager={tokenManager} revalidateKey={revalidateKey} > {children} </SessionProvider> ); }
As with the async flavor, application code imports useSession from @auth/SessionProvider; the install selects this flavor for credentialStorageType: "browser".
| Configuration | Value |
|---|---|
credentialStorageType | browser |
useSessionFlag surfaces readiness for this flavor