useConfig(key) returns one configuration value. The first render shows the cached value or the
default. The hook then fetches the current value from the API and re-renders when it arrives.
Configuration values are strings. Read Remote configuration.
Signature
Options
Result
Cache-first behavior
- On the first render, the hook reads
client.getConfig(key). The result comes from the cache or fromdefaultConfigurations. There is no loading state. - After mount, the hook calls
client.fetchConfigwith the options. When the response holds the key,valueupdates and the component re-renders. - The hook subscribes to the configuration change listener of the client. When any fetch or the
refresh timer changes the key,
valueupdates. - When the fetch fails,
errorholds the failure andvaluekeeps the cached or default value.
key, forceRefresh, immediateKeys, or properties change.
Default values
SetdefaultConfigurations on the provider. The first render shows the default, also when the
device is offline.
Feature flag
Values are strings. Compare with'true'. Read Feature flags.
Personalized value
Refresh and errors
Several keys
CalluseConfig one time per key. Each call re-renders only when its own key changes. For many
keys, or to iterate over all keys, read useAllConfigs.