React
React hooks and the provider that read a client's state.
import { … } from "@monarcode/session-kit/react";Guide: Read the session in React.
Functions
createAuthHooks
Creates React hooks typed for one auth client. Each call has its own context, so an app with several clients calls it once per client. With TanStack Router, pass useRouterAuth as useClient instead of rendering AuthProvider. See AuthHooksOptions.
useMirrorAuth
Creates a createMirrorAuth client once, from the session the page was rendered with, and keeps it in step with your server. Call it in the component that renders AuthProvider.
Types
AuthHooks
The provider and hooks createAuthHooks returns, typed for one client.
AuthHooksOptions
Options for createAuthHooks.
Prop
Type
AuthProviderProps
Props for the AuthProvider that createAuthHooks returns.
Prop
Type
AuthSource
What the React bindings need from an auth client: its state, and mount to start background work while rendered. A createAuth or createMirrorAuth client fits.
StateOf
The state type of a client: what useAuth() returns (AuthState).