Aura Auth
API ReferenceClientFunctions

getSession

Get the current session for a user with Aura Auth.

The getSession client method retrieves the active user session from a client-side or browser context. It verifies the session token's integrity and returns the associated user data if the session is valid.

syntax.ts
import { authClient } from "@/lib/auth-client"

const session = await authClient.getSession()

Reference

This function accepts no parameters — session data is read automatically from the browser's cookies.

Returns

Return TypeDescription
Promise<Session<DefaultUser> | null>Resolves to the current session object, or null.

This return shape is intentionally simpler than the server-side api.getSession, which returns { session, success, headers }. The client doesn't need the headers field that server-side rolling session rotation requires — the browser already handles the refreshed cookie automatically.

Behavior

  • Cookies are read automatically from the browser context — you don't need to handle them manually.
  • If there is no valid session (missing, expired, or tampered token), the resolved value is null. This does not throw — a missing session is an expected, non-error outcome.

Usage

Get the current session

get-session.ts
import { authClient } from "@/lib/auth-client"

const session = await authClient.getSession()

Guarding a route

protected-route.ts
import { authClient } from "@/lib/auth-client"

const session = await authClient.getSession()

if (!session) {
  window.location.assign("/login")
}

On this page