Skip to Content
Packages@tuwaio/siwx-reactVariablesuseSiwxSessionStore

useSiwxSessionStore

const useSiwxSessionStore: UseBoundStore<WithImmer<WithPersist<StoreApi<SiwxSessionStore>, { session: SiwxClientSession | null; }>>>

Defined in: siwx-react/src/sessionStore.ts:160 

Zustand store (with the immer and persist middlewares) that holds the client-side SIWX sign-in state. Use it as a hook, optionally with a selector: useSiwxSessionStore((state) => state.session).

Remarks

The authenticated session is saved to localStorage under the key siwx-react:session and cleared by reset. It is restored after a page reload when useSiwx or useSiwxSession first mounts (not during server rendering, so there is no hydration mismatch), unless its expirationTime has passed; outside React call useSiwxSessionStore.persist.rehydrate(). Only the session is saved, never the status of a sign-in in progress.

The store is a module-level singleton shared by every component, and it is UI state only: servers must verify the session cookie, never trust this store.

Last updated on