User attributes
Store and update custom fields on the signed-in user, with a full change history.
User attributes are custom key-value fields on a user account - onboarding state, plan preferences, anything your app needs to remember about a person rather than a workspace.
import { useUserAttributes } from '@buildbase/sdk/react';
function OnboardingGate({ children }: { children: React.ReactNode }) {
const { attributes, loading, updateAttribute } = useUserAttributes();
if (loading) return <Spinner />;
if (attributes?.onboarded) return <>{children}</>;
return <OnboardingFlow onDone={() => updateAttribute('onboarded', true)} />;
}Before you start
Define your attribute keys in the BuildBase console, as the next section shows, so they are available for audience segmentation and workflow conditions. Writing an undefined key still stores it, within the limits below, but it will not appear as a filterable field.
Define an attribute in the console
Open User attributes in the console
(opens the console in a new tab)- In the left rail choose Users, then Attributes under Users. The page is User attributes.
- Press Create attribute. Your plan sets how many attributes you may define.

- Fill Name (what your team reads, such as
Plan interest) and Key (what your code uses, lowercase letters, digits and hyphens, such asplan-interest; it cannot be changed later), and pick the Type: String, Number, Boolean, Date or Dropdown. - For a Dropdown, give each choice a label and a value, pressing Add option for each one after the first.

- Optionally set a Default value and a Description. Then decide Allow public edit (the person can change it, through
updateAttribute) and Allow public view (the person can see it, throughuseUserAttributes), and press Create.

With Allow public view off, the value never reaches the person: useUserAttributes leaves it out, and so does the user that updateAttribute, updateAttributes and a profile update answer with. Use it for what you keep about a person and do not show them, such as an internal score or a sales note.
The attribute is then in the list, where Access says who may see and edit it.

- It is also a filter on the Users list: press Filters there and it is at the end, by its name.

- To set one person's value by hand, open them from the Users list and press Manage attributes (looking after a user).

What the hook returns
| Field | Type | Description |
|---|---|---|
attributes | Record<string, string | number | boolean> | Current values |
loading | boolean | True while the attributes fetch is in flight |
error | string | null | Fetch error, if any |
refetch() | () => Promise<void> | Re-read attributes from the server |
updateAttribute() | (key, value) => Promise<IUser> | Write one attribute |
updateAttributes() | (updates) => Promise<IUser> | Write several at once |
Values are limited to string, number, and boolean. Store an object by
serializing it yourself, and keep in mind that segmentation cannot filter inside
a serialized blob.
Both update methods resolve to the full updated user, not just the attributes, so you can read other profile fields from the same response.
Warning
useUserAttributes() throws if it is called outside the provider tree, with
"must be used within a UserProvider". If you see that error, the component is
mounted above SaaSOSProvider.
Two returned fields are deprecated: isLoading combines the attributes and
features pipelines, so a features fetch flips it; and refreshAttributes is
the old name for refetch. Use loading and refetch.
Writing one value versus several
updateAttribute is a convenience wrapper. Prefer updateAttributes when you
have more than one change - it is a single request, so there is no window where
half the changes are visible:
const { updateAttributes } = useUserAttributes();
await updateAttributes({
onboarded: true,
plan_interest: 'scale',
seats_estimate: 25,
});Limits
Attributes are written by the signed-in user, from their own browser, so the
server bounds what one person can store. A write over a limit is refused with
a 400 and a message saying which one, and nothing in it is saved.
| Limit | Value |
|---|---|
Keys in one updateAttributes() call | 100 |
| Key length | 1 to 100 characters |
| Key characters | Letters, digits, _ and -, starting with a letter or digit |
| String value length | 1,024 characters |
| Undefined keys one user can hold | 100 (keys you defined in the console do not count) |
| All of one user's attributes, serialized | 64 KB |
onboarded, plan_interest, onboardingStep and a console key such as
plan-tier are all valid keys. A key with a ., a $ or a space is not.
The last two limits are on what the user holds rather than on one request, so a write that would take the user past either is refused. A user who already holds more than that from before these limits can still update the values they have, as long as the write does not make their attributes bigger.
Warning
A signed-in user can write any key you have not defined in the console, and
any you defined as editable by them. Never read an attribute such as role or
isAdmin to decide what someone may do: use roles and
permissions for that.
Change history
Every change to a user attribute, from updateAttribute in your app or from Manage attributes in the console, is recorded with its old and new value. The console does not show this history yet, and the admin API has no route that reads it.
The Attributes card on a contact's page under Audience has a history of its own, but it is for audience attributes, which you define under Audience, Attributes, and which are separate from user attributes (audience and lists).
Attributes versus feature flags
They look similar and are not interchangeable:
| User attributes | User feature flags | |
|---|---|---|
| Written by | Your app, at runtime | The console |
| Purpose | Remember something about the user | Decide what the user may see |
| Read with | useUserAttributes() | useUserFeatures(), WhenUserFeatureEnabled |
If your app decides the value, it is an attribute. If you want to change behavior without a deploy, it is a flag.
Next Steps
- Audience and lists - segment on these attributes.
- Feature flags - gate features per user.