Firebase Remote Config: Dynamic App Configuration Without Updates
In this tutorial, you will learn about Firebase Remote Config: Dynamic App Configuration Without Updates. We cover key concepts, practical examples, and best practices to help you master this topic.
Firebase Remote Config lets you change your app's appearance and behavior dynamically, updating feature flags, UI text, or API endpoints without requiring an app update.
What You'll Learn
How to use Remote Config to manage feature flags, roll out changes gradually, A/B test configurations, personalize settings per user segment, and fetch configs efficiently.
Why It Matters
App store updates take days to approve. Remote Config changes take effect in minutes. DodaTech uses Remote Config to enable/disable experimental threat detection features, adjust scan frequency, and show promotional banners — all without app updates.
Real-World Use
A new threat detection algorithm needs gradual rollout. Remote Config defines the rollout percentage. 10% of users get the new algorithm, monitored for 48 hours, then rolled to 100%.
flowchart LR
A["Remote Config\nConsole"] --> B["Set Parameters\n+ Conditions"]
B --> C["Fetch Config\nClient SDK"]
C --> D{"Rollout %\nCondition?"}
D -->|"10%"| E["New Algorithm\nGroup A"]
D -->|"90%"| F["Current Algorithm\nGroup B"]
style A fill:#dbeafe,stroke:#2563eb
style C fill:#fef3c7,stroke:#d97706
style D fill:#bbf7d0,stroke:#16a34a
Setting Up Remote Config
import { getRemoteConfig, fetchAndActivate, getValue } from "firebase/remote-config";
const remoteConfig = getRemoteConfig();
// Set minimum fetch interval (seconds)
remoteConfig.settings.minimumFetchIntervalMillis = 3600000; // 1 hour
// Set default values
remoteConfig.defaultConfig = {
welcome_message: "Welcome to Doda Antivirus",
scan_frequency_hours: 24,
new_algorithm_enabled: false,
max_device_count: 5,
premium_feature_prompt: ""
};
async function initializeConfig() {
await fetchAndActivate(remoteConfig);
console.log("Remote config fetched and activated");
}
Reading Config Values
async function appStartup() {
await initializeConfig();
// Read different types
const welcomeMessage = getValue(remoteConfig, "welcome_message").asString();
const scanFrequency = getValue(remoteConfig, "scan_frequency_hours").asNumber();
const newAlgorithm = getValue(remoteConfig, "new_algorithm_enabled").asBoolean();
const maxDevices = getValue(remoteConfig, "max_device_count").asNumber();
console.log("Settings:", {
welcomeMessage,
scanFrequency,
newAlgorithm,
maxDevices
});
// Apply config
if (newAlgorithm) {
enableThreatAlgorithmV2();
}
scheduleScans(scanFrequency);
}
// Expected output: Settings: { welcomeMessage: "Welcome to Doda Antivirus", scanFrequency: 24, newAlgorithm: false, maxDevices: 5 }
Feature Flags Example
function initializeFeatureFlags() {
const experimentalUI = getValue(remoteConfig, "experimental_ui_enabled").asBoolean();
const showBanner = getValue(remoteConfig, "show_promo_banner").asBoolean();
const bannerText = getValue(remoteConfig, "promo_banner_text").asString();
if (experimentalUI) {
renderNewDashboard();
} else {
renderCurrentDashboard();
}
if (showBanner && bannerText) {
displayBanner(bannerText);
}
console.log("Feature flags applied:", {
experimentalUI,
showBanner
});
}
Server-Side Remote Config
// Access Remote Config from Cloud Functions
const { remoteConfig } = require("firebase-admin").remoteConfig();
async function getServerConfig() {
const template = await remoteConfig.getTemplate();
const parameters = template.parameters;
console.log("Server config parameters:");
Object.entries(parameters).forEach(([key, param]) => {
console.log(key, ":", param.defaultValue.value);
});
return parameters;
}
// Expected output: Server config parameters:
// welcome_message : Welcome to Doda Antivirus
// scan_frequency_hours : 24
Gradual Rollout
Configure in Firebase Console:
// In Remote Config Console, set:
// Parameter: new_algorithm_enabled
// Default value: false
// Condition: "Rollout 10%" → true
// Condition type: Percentile
// Percentile: 10
// Bucket: Random
// Client code — no changes needed
const isEnabled = getValue(remoteConfig, "new_algorithm_enabled").asBoolean();
if (isEnabled) {
console.log("Using new threat detection algorithm");
} else {
console.log("Using current threat detection algorithm");
}
Common Mistakes
1. Fetching Config Too Frequently
Fetching Remote Config on every app launch or screen load increases latency and costs. Set a reasonable minimum fetch interval (15-60 minutes for most apps).
2. Not Setting Default Values
If the fetch fails or times out, the app uses no value — causing unexpected behavior. Always set defaultConfig with safe fallback values.
3. Using Remote Config for Secrets
Remote Config values are delivered to the client and can be inspected. Never store API keys, passwords, or other secrets in Remote Config.
4. Forgetting to Activate Fetched Config
Fetching config doesn't apply it. You must call activate() or use fetchAndActivate() to make fetched values available.
5. Not Testing with Throttled Network
Remote Config fetch can fail on slow networks. Test your app with airplane mode or throttled connections to verify fallback behavior.
Practice Questions
- How does Remote Config differ from environment variables?
- What is the purpose of minimum fetch interval?
- How do you roll out a feature to 20% of users?
- Can Remote Config be used server-side?
Answers:
- Environment variables are compile-time constants. Remote Config values can be changed at runtime without app updates, targeting specific conditions.
- It controls how frequently the SDK fetches from the server. Higher intervals reduce network usage but delay config updates.
- Create a percentile condition in Remote Config Console set to 20%, assign the parameter to true conditionally, false by default.
- Yes, the Admin SDK provides
remoteConfig().getTemplate()to read parameters server-side in Cloud Functions.
Challenge: Set up Remote Config for a feature rollout: define 5 parameters (feature flag, scan frequency, welcome message, promotional text, max devices), set default values, create a 25% rollout condition for a new UI, and test with the mobile app.
FAQ
Mini Project
Set up Remote Config for a feature management system: define flags for experimental UI, scan frequency, max connected devices, and promotional banner. Implement gradual rollout (25% for new UI), set defaults, and test offline fallback behavior.
What's Next
Firebase Analytics — track user behavior and measure app performance.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro