Loading…
Loading…
Server-bootstrapped session provider for the cookie credential-storage flavor
The cookie / async session flavor, used when credentialStorageType: "cookies". The session is bootstrapped on the server (from an HTTP-only cookie) and hydrated on the client; useSession reads it through a Suspense-style gate so session-dependent UI waits until the async session has settled (which prevents SSR stream hangs). Drives its store with useAsyncSessionManager from @woographql/react-hooks.
Exported from the client entry point, @woographql/next.
import { AsyncSessionProvider, createSessionContext, useSessionReadyGate, } from '@woographql/next';
| Export | Signature | Description |
|---|---|---|
AsyncSessionProvider | <T>(props) => JSX.Element | Client provider component. Props: context, operations, tokenManager (async), revalidateKey, optional initialState + config. |
createSessionContext | <SD, TM>(initialState?: Partial<SD>) => { context, useSession, useCartMutations, … } | Factory that builds the typed session context + the bound useSession / useCartMutations hooks the app consumes. |
useSessionReadyGate | (context) => void | Hook that defers rendering of session-dependent UI until the async session for the given context has hydrated. |
revalidateKey is wired to the session flag so the store re-fetches when server-side auth state changes.
// @auth/SessionProvider (generated) wires the pieces; conceptually: 'use client'; import { AsyncSessionProvider, createSessionContext } from '@woographql/next'; const { context, useSession } = createSessionContext(); export function Providers({ children, initialState, tokenManager, operations, revalidateKey }) { return ( <AsyncSessionProvider context={context} operations={operations} tokenManager={tokenManager} revalidateKey={revalidateKey} initialState={initialState} > {children} </AsyncSessionProvider> ); }
Application code imports useSession from @auth/SessionProvider, not from here directly.
| Configuration | Value |
|---|---|
credentialStorageType | cookies |
revalidateKey