Skip to Content
Using the client

Updating the user

Replace the signed-in user without ending the session, safely across account switches.

auth.updateUser replaces the user and keeps the session. When you already have the new user, such as from a form's response, pass it directly: auth.updateUser(user).

When the new user comes from a request, pass a function that fetches it instead. The client notes the session before the function runs. If the session changes meanwhile, updateUser rejects with SESSION_CHANGED, and the user it fetched never lands on another account. fetchProfile is the request from Getting started:

src/profile.ts
import {  } from "./api.js";
import {  } from "./auth.js";

export const  = () => .();