Aura Auth
API ReferenceClientFunctions

updateSession

Update the current session with new identity data or refresh the session.

The updateSession client method modifies or refreshes the data stored in the current user's session payload, without requiring them to sign out and back in.

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

const session = await authClient.updateSession({
  session: {
    user: {
      nickname: "newnickname",
    },
  },
})

Reference

Parameters

ParameterTypeRequiredDescription
optionsUpdateSessionOptions<DefaultUser>YesAn object containing the session updates and request context.

UpdateSessionOptions

OptionTypeDefaultDescription
sessionDeepPartial<Session<DefaultUser>>undefinedThe partial session data to merge into the current session.
redirectbooleantrueWhether to redirect via window.location.assign (true) or return the result as an object (false).
redirectTostringundefinedThe URL to redirect to after a successful update.

Returns

Return TypeDescription
Promise<UpdateSessionReturn<Options>>Resolves to an object containing the updated session data, redirect, and success.

Behavior

  • Cookies are set automatically in the browser context — you don't need to handle them manually.
  • The CSRF token is automatically loaded and sent with the request — you don't need to handle it manually.
  • The session token's integrity is verified before applying the update. If the session is invalid or expired, the call resolves with success: false rather than throwing.
  • The return value depends on the redirect option:
    • redirect: true (default) — navigates to redirectTo (or the default post-update URL) via window.location.assign.
    • redirect: false — resolves to an object with the updated session, redirect: false, and success, letting you handle navigation yourself.
  • If the update fails (invalid session, or data that doesn't match identity.schema), success is false.

Usage

Update session data

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

const session = await authClient.updateSession({
  session: {
    user: {
      nickname: "newnickname",
    },
  },
})

With navigation

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

const output = await authClient.updateSession({
  session: {
    user: {
      nickname: "newnickname",
    },
  },
  redirect: false,
  redirectTo: "/dashboard",
})

if (output.success) {
  window.location.assign(output.redirectURL)
}

On this page