Core Concepts

Sessions

SSR‑safe session state via `useUserSession()`.

useUserSession() is auto‑imported on the client and server.

const {
  user,
  session,
  loggedIn,
  ready,
  signIn,
  signUp,
  signOut,
  fetchSession,
} = useUserSession()

SSR behavior

  • On the server, the module initializes state but does not fetch a session.
  • On the client, a plugin calls fetchSession() on first load.
  • ready flips to true after the first fetch attempt.

Use ready or <BetterAuthState> when you need to wait for hydration.

See also