Skip to content

Remote Config

firekitRemoteConfig lets you fetch configuration values from Firebase Remote Config and use them reactively in your app. Values can be fetched once or subscribed to with real-time updates.

import { firekitRemoteConfig } from 'svelte-firekit';
const rc = firekitRemoteConfig({
defaults: {
welcomeMessage: 'Hello!',
featureEnabled: false,
itemsPerPage: 10,
},
minimumFetchIntervalMs: 3_600_000, // 1 hour (default)
});
// Fetch and activate the latest config
await rc.fetchAndActivate();
const message = rc.getString('welcomeMessage');
const enabled = rc.getBoolean('featureEnabled');
const count = rc.getNumber('itemsPerPage');
const raw = rc.getValue('someKey'); // returns a Value object

Defaults are returned when the key has not been fetched yet or does not exist in Remote Config.

Pass realtime: true to subscribe to live config updates as they are published in the Firebase console:

const rc = firekitRemoteConfig({
defaults: { featureEnabled: false },
realtime: true,
});
await rc.fetchAndActivate();

When a new config version is published, rc automatically fetches and activates it.

OptionTypeDefaultDescription
defaultsRecord<string, string | number | boolean>{}Default values used before fetch
minimumFetchIntervalMsnumber43200000 (12h)Minimum interval between fetches
realtimebooleanfalseSubscribe to live config updates
fetchTimeoutMillisnumber60000Fetch timeout in ms
<script lang="ts">
import { firekitRemoteConfig } from 'svelte-firekit';
import { onMount } from 'svelte';
const rc = firekitRemoteConfig({
defaults: {
bannerMessage: 'Welcome!',
showBanner: false,
},
});
onMount(async () => {
await rc.fetchAndActivate();
});
</script>
{#if rc.getBoolean('showBanner')}
<div class="banner">
{rc.getString('bannerMessage')}
</div>
{/if}
PropertyTypeDescription
loadingbooleantrue while fetching config
lastFetchStatusstringLast fetch result ('success', 'failure', 'no-fetch-yet', 'throttle')
// Fetch only (does not apply to active config)
await rc.fetch();
// Fetch and apply immediately
await rc.fetchAndActivate();
// Apply the most recently fetched config (if not yet activated)
await rc.activate();