What is Remote Configuration?
Remote configuration lets you change how your app behaves without shipping new code. Update text, toggle features, or change colors - all from the Grain dashboard. Traditional way:Why Use Remote Config?
A/B Testing: Show variant A to some users, variant B to others:Cache-First Strategy
This is the key to making remote config fast. Grain uses a cache-first approach:- First access: Return default or cached value (instant)
- Background fetch: Load fresh values from API
- Update: When new values arrive, update cache and notify listeners
Setting Defaults
Always provide default values for immediate access:getConfig() returns undefined until values load from the API.
Getting Configuration Values
Synchronous Access
Get values instantly from cache or defaults:Asynchronous Access
Fetch fresh values from the API:Get All Configurations
Preloading Configurations
Preload configs at app startup for instant access:Configuration Change Listeners
React to configuration changes in real-time:- After background fetch completes
- When manual refresh happens
- When cache updates
Personalized Configurations
Pass user properties to get personalized values:Practical Examples
Feature Flag
A/B Test
Dynamic Styling
Emergency Control
Auto-Refresh
Configs automatically refresh in the background:0 to disable auto-refresh.
Caching
Configs are cached inlocalStorage (or memory in Node.js):
Managing Configs
Configure values in the Grain dashboard:- Go to grainql.com/dashboard
- Navigate to Remote Config
- Create configuration keys
- Set default values
- Add rules for personalization
- Publish changes