13. State & Cache
context.state
sync· returnsRecord<string, any>
A runtime key-value store scoped to the current page session. Use it to share transient data between functions on the same page without persisting to the database.
// Set a value
context.state.selectedItemId = "42";
// Read it elsewhere on the same page
var id = context.state.selectedItemId;
context.clearEntityCache()
sync· returnsvoid
Clears all locally cached entity data, forcing the next read to fetch fresh data from the server. Use sparingly — prefer context.mutate(slug) for targeted invalidation.
context.clearEntityCache();
await context.getEntities("invoices");
context.user
sync· returnsobject
Returns the currently logged-in user's profile data.
var currentUser = context.user;
console.log("Logged in as:", currentUser.FullName);
Returned value:
{
"ID": "7",
"FullName": "John Smith",
"Email": "john.smith@company.com",
"RoleId": "2",
"CreateDate": "2025-01-10T08:00:00Z",
"CreateUser": { "ID": "1", "FullName": "Mileva Service" },
"ModifyDate": "2026-02-14T09:30:00Z",
"ModifyUser": { "ID": "1", "FullName": "Mileva Service" },
"SystemStatusID": { "ID": "1", "Name": "Active" }
}
context.primaryColor
sync· returnsstring
Returns the application's primary theme colour as a hex string. Useful for dynamically styling custom components to match the app's theme.
var color = context.primaryColor;
// → "#6C47FF"