Skip to main content
Call updateUser() to update profile fields (name, email, metadata) for the user attached to the current session. Use this for partial user updates as context evolves during the session — e.g. the user upgrades their plan, switches teams, or completes onboarding. User metadata has upsert semantics across the user’s lifetime: any fields you provide are merged with previously set values, so you only need to send what has changed.
updateUser() does not re-attribute an already-identified session. Once a session is linked to a user (via the first identify or updateUser call), subsequent updateUser calls with a different userId will not move the session to a different user — they only update the named user’s metadata.For the initial “user just signed in” flow with a known email, identify() is the more focused entry point. For session-level metadata, use updateSession().
Use the useMilana() hook:
import { useMilana } from "milana-js/react";

function UpgradeButton() {
  const { updateUser } = useMilana();

  const handleUpgrade = async (newPlan: string) => {
    await billing.upgrade(newPlan);
    void updateUser({
      userId: currentUser.id,
      metadata: { plan: newPlan },
    });
  };

  return <button onClick={() => handleUpgrade("pro")}>Upgrade</button>;
}

Parameters

userId
string
required
A stable, unique identifier for the user in your system. Use your database user ID or a similar permanent identifier — do not use an email address as the primary ID. Pass the same userId as your prior identify call; a different userId will not re-attribute the session.
email
string
The user’s email address. Used to connect user identity across your systems (e.g. support tools, CRM, data warehouse) and displayed in the dashboard.
name
string
The user’s display name.
metadata
object
Arbitrary key-value pairs to attach to the user. Keys are strings, values can be string, number, boolean, null, or nested objects/arrays of the same types. e.g. plan, team, country, role, accountType.

Return value

success
boolean
true if the update was applied. false if the session was not active, the network request failed, or the session was not sampled.

Timing

updateUser() is safe to call before init() completes — the SDK queues the call and replays it once the session is ready.