Skip to main content

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:
With remote config:
Now you can update that text from the dashboard and all users see the new version instantly.

Why Use Remote Config?

A/B Testing: Show variant A to some users, variant B to others:
Feature Flags: Enable/disable features without code:
Personalization: Different content for different users:
Emergency Off Switch: Disable broken features instantly:

Cache-First Strategy

This is the key to making remote config fast. Grain uses a cache-first approach:
  1. First access: Return default or cached value (instant)
  2. Background fetch: Load fresh values from API
  3. Update: When new values arrive, update cache and notify listeners
Your app never waits for the network. It shows content immediately with cached or default values.

Setting Defaults

Always provide default values for immediate access: Using the Grain Tag:
Or with the npm package:
Without defaults, getConfig() returns undefined until values load from the API.

Getting Configuration Values

Synchronous Access

Get values instantly from cache or defaults:
Use this in render functions, event handlers, or anywhere you need instant access.

Asynchronous Access

Fetch fresh values from the API:
This still uses cache-first: returns cached value immediately, then fetches fresh value in background. Force refresh:

Get All Configurations

Preloading Configurations

Preload configs at app startup for instant access:
This is perfect for loading critical configs before rendering your UI.

Configuration Change Listeners

React to configuration changes in real-time:
When listeners fire:
  • After background fetch completes
  • When manual refresh happens
  • When cache updates
Remove listeners when no longer needed:

Personalized Configurations

Pass user properties to get personalized values:
How it works: Grain evaluates rules based on these properties and returns values matched to the user. Premium users might see different text than free users. Set up rules in the Grain dashboard to define which users see which values.

Practical Examples

Feature Flag

A/B Test

Dynamic Styling

Emergency Control

Auto-Refresh

Configs automatically refresh in the background:
Default is 5 minutes. Set to 0 to disable auto-refresh.

Caching

Configs are cached in localStorage (or memory in Node.js):
Why cache? Your app loads instantly with previously fetched values, even offline. Disable caching if needed:

Managing Configs

Configure values in the Grain dashboard:
  1. Go to grainql.com/dashboard
  2. Navigate to Dashboard > Remote Config
  3. Create configuration keys
  4. Set default values
  5. Add rules for personalization
  6. Publish changes
Changes take effect immediately for all clients.

Next Steps

A/B Testing Guide

Build A/B tests with remote config

Feature Flags Guide

Implement feature flags

Personalization

Create personalized experiences

Config Methods API

See all configuration methods