What is @firebase/remote-config?
The @firebase/remote-config package is part of the Firebase platform and provides tools to configure and customize the behavior and appearance of your app without needing to publish an app update. It allows developers to define parameters in the Firebase Console and use them in their app to modify app behavior for different users.
What are @firebase/remote-config's main functionalities?
Fetch and activate values
This feature allows developers to fetch remote configuration parameters and activate them in the app. The code sample demonstrates fetching and activating remote config values, then retrieving a specific parameter as a string.
const { getRemoteConfig, fetchAndActivate } = require('@firebase/remote-config');
async function fetchConfig() {
const remoteConfig = getRemoteConfig();
await fetchAndActivate(remoteConfig);
const value = remoteConfig.getString('welcome_message');
console.log('Welcome message:', value);
}
Set default values
This feature enables setting default values for configuration parameters within the app code. The code sample shows how to set a default value for a 'welcome_message' parameter, which will be used if no value is fetched from the server or while waiting for updated values.
const { getRemoteConfig, setDefaults } = require('@firebase/remote-config');
function setDefaultConfig() {
const remoteConfig = getRemoteConfig();
setDefaults(remoteConfig, {
'welcome_message': 'Hello, default!'
});
}
Other packages similar to @firebase/remote-config
config
The 'config' package is used for managing configuration settings for Node.js applications. It does not support remote configuration management but is useful for organizing configuration settings within an application. Unlike @firebase/remote-config, it does not allow for dynamic updates from a remote server.
dotenv
The 'dotenv' package is used to load environment variables from a .env file into process.env, providing a simple way to configure application settings. It differs from @firebase/remote-config as it does not support fetching configurations remotely or updating them without redeploying the application.
@firebase/remote-config
This is the Remote Config component of the
Firebase JS SDK.
This package is not intended for direct usage, and should only be used via the officially
supported firebase package.
Contributing
Setup:
- Run
yarn
in repo root
Format:
- Run
yarn prettier
in RC package
Unit test:
- Run
yarn test
in RC package
End-to-end test:
- Run
yarn build
in RC package - Run
yarn build
in Firebase package - Open test_app/index.html in a browser