Set properties when they change or when a user first signs up:
// After signupgrain.setUserId('user_123');await grain.setProperty({ plan: 'free', signup_date: new Date().toISOString(), source: 'landing_page'});// When user upgradesawait grain.setProperty({ plan: 'premium', upgrade_date: new Date().toISOString()});// When preferences changeawait grain.setProperty({ theme: 'dark', language: 'es'});
Override which user receives properties using options:
// Set properties for a different userawait grain.setProperty({ status: 'inactive'}, { userId: 'user_456' });
Security: Only use userId overrides when you have permission to modify other users. With JWT auth, the user ID must match your token. Learn more in Security.
Properties power remote configuration personalization. When fetching configs, pass properties to get personalized values:
// User properties influence which config values are returnedconst heroText = await grain.getConfigAsync('hero_text', { properties: { plan: 'premium', location: 'US' }});
For example, premium users might see “Welcome back, premium member!” while free users see “Upgrade to premium!”.This is covered in depth in Remote Configuration and Personalization Guide.
Setting properties for many different user IDs from the same source may trigger rate limiting. This prevents one client from modifying many user profiles.Learn more in Security.