User Variables
User variables are key-value pairs stored on the server for each individual user. Unlike server-sided variables, user variables are personal to each user and can be read and written by the user themselves.
Why Use User Variables?
Store per-user data on the server instead of locally:
- Sync across devices - Settings follow the user, not the device
- Persist after reinstalls - Data survives app reinstalls or device changes
- Server-side storage - Keep user-specific data secure on your server
How They Work
- Each variable has a name (up to 64 characters) and a value (up to 10,000 characters)
- Variables are automatically created when set for the first time
- Only authenticated users can access their own variables
- Each user has their own separate set of variables
Use Cases
Example: User Preferences
Store theme settings, language preferences, or UI customizations:
// Save user preference
client.set_user_variable("theme", "dark");
// Retrieve it later (even on a different device)
std::string theme = client.get_user_variable("theme");Example: Application State
Save progress, last-used settings, or session data:
// Save current level
client.set_user_variable("current_level", "5");
// Save last opened project
client.set_user_variable("last_project", "project-123");User Variables vs Server-Sided Variables
| Feature | User Variables | Server-Sided Variables |
|---|---|---|
| Who sets them | Users (via your app) | You (via admin panel) |
| Scope | Per user | App-wide |
| Access | Only the owner | All authenticated users |
| Use case | User preferences, state | API keys, config, feature flags |
Last updated on