Skip to content

Feature Flags Quickstart

This is the flags-only path: no auth setup, no billing, no user records. You need a Bridge app ID from app.thebridge.dev.

Terminal window
npm install @nebulr-group/bridge-svelte

Bootstrap Bridge in your root layout. For flags-only, the config is just your app ID and all routes stay public:

src/routes/+layout.ts
import type { LayoutLoad } from './$types';
import type { BridgeConfig, RouteGuardConfig } from '@nebulr-group/bridge-svelte';
import { bridgeBootstrap } from '@nebulr-group/bridge-svelte';
export const ssr = false;
export const load: LayoutLoad = async ({ url }) => {
const config: BridgeConfig = {
appId: import.meta.env.VITE_BRIDGE_APP_ID,
};
const routeConfig: RouteGuardConfig = {
rules: [{ match: /.*/, public: true }],
defaultAccess: 'public',
};
await bridgeBootstrap(url, config, routeConfig);
return {};
};
src/routes/+layout.svelte
<script lang="ts">
import { BridgeBootstrap } from '@nebulr-group/bridge-svelte';
// Keep the flags module on the dependency graph — BridgeBootstrap
// auto-attaches it (rule cache, live updates, telemetry).
import '@nebulr-group/bridge-svelte/flags';
let { children } = $props();
</script>
<BridgeBootstrap />
{@render children()}

The default value is mandatory — it’s returned whenever the flag isn’t configured yet or Bridge is unreachable, so a flag call can never break your app. The flag’s type (boolean, string, number, or JSON) is inferred from the default.

<script lang="ts">
import { useFlag, FeatureFlag } from '@nebulr-group/bridge-svelte/flags';
const banner = useFlag('show_banner', false);
</script>
{#if banner.value}
<div class="banner">We shipped something new!</div>
{/if}
<!-- Or declaratively: -->
<FeatureFlag key="show_banner" defaultValue={false}>
<div class="banner">We shipped something new!</div>
</FeatureFlag>

useFlag is reactive — when the flag changes (admin edit, rule change, kill switch), the value updates in place.

You don’t register flags manually. The first time your code evaluates show_banner, the key self-announces to Bridge and appears in the Flags list with a Discovered badge. Open it, pick one of the three states — Off for everyone, On for everyone, or On for users matching a rule — and save.

With your app open, flip the flag in the admin. The change reaches every connected app in about a second — the SDK receives the new rule over a live channel and re-evaluates locally. No refresh, no polling, no code.

If the connection drops, your app keeps working on last-known values and refetches on reconnect.