Remote Config

Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update.

1. Use Cases

  • Feature Toggles: Enable or disable features for specific user segments.
  • Design Changes: Change the theme or layout for seasonal promotions.
  • A/B Testing: Test different versions of a feature to see which performs better.

2. Basic Implementation

import { getRemoteConfig, getValue, fetchAndActivate } from "firebase/remote-config";

const remoteConfig = getRemoteConfig();
remoteConfig.settings.minimumFetchIntervalMillis = 3600000; // 1 hour

fetchAndActivate(remoteConfig)
  .then(() => {
    const welcomeMessage = getValue(remoteConfig, "welcome_msg").asString();
    console.log(welcomeMessage);
  });

3. Setting Default Values

Always provide default values for when a device is offline or config hasn't been fetched yet.

remoteConfig.defaultConfig = {
  "welcome_msg": "Welcome to our App!"
};
Pro Tip: Use Remote Config with A/B Testing to validate product changes before rolling them out to all users.