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.
- React
- JavaScript
- Script Tag
Use the
useMilana() hook:Parameters
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.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.
The user’s display name.
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
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.