Amba
SDKsFeatures

Remote config

Fetch a per-user key/value bundle for runtime configuration. ETag-cached, version-stamped.

config.fetch() returns a resolved key/value bundle for the signed-in user. Use it for values that the app reads on launch and needs to be able to change without a redeploy — pricing, copy, feature thresholds, default selections.

Unlike feature flags, config bundles are designed for strings, numbers, and structured config, not boolean gates. One bundle per project, evaluated per user against rules you define in the console.

Quick start

import { Amba } from '@layers/amba-web';
 
const bundle = await Amba.config.fetch();
console.log(bundle.version); // e.g. 'v42'
console.log(bundle.values); // { onboarding_steps: 3, hero_copy: '...', ... }

Operations

fetch()

Returns a single bundle:

{
  version: 'v42',       // version stamp set in the console
  values: {
    hero_copy: 'Welcome to amba',
    onboarding_steps: 3,
    pricing: {
      pro_monthly: 999,
      pro_annual: 9999,
    },
  },
}

The SDK caches the response per-session and revalidates with the server using an ETag — if the server's version hasn't changed, the SDK returns the cached values without a fresh body transfer.

Patterns

Boot-time config

For values you need at app launch (splash screen copy, theme, etc.), fetch synchronously on boot and hold the result in memory:

let configCache: Awaited<ReturnType<typeof Amba.config.fetch>> | null = null;
 
export async function bootConfig(): Promise<void> {
  configCache = await Amba.config.fetch();
}
 
export function getConfig<T = unknown>(key: string, fallback: T): T {
  return ((configCache?.values as Record<string, unknown>)?.[key] as T) ?? fallback;
}

Per-flag vs. config

Use feature flags for on/off decisions and A/B variant assignment. Use config for values like copy, pricing, thresholds:

// Flag: "is this user in the new-checkout cohort?"
const newCheckout = useFlag('new_checkout');
 
// Config: "what discount do they see today?"
const config = await Amba.config.fetch();
const discount = config.values?.checkout_discount ?? 0;

Both are evaluated per-user; the difference is in the surface ergonomics (flags.fetch() returns an array of boolean/variant assignments; config.fetch() returns a single typed bundle).

Refresh

Config caches for ~60 seconds within a session, then revalidates on next fetch(). To force a fresh fetch (e.g. after a known server-side update), sign the user out and back in — the cache is keyed by session.

Limits

  • Bundle size: up to 256 KB JSON-encoded.
  • Key count: up to 100 top-level keys; nest deeper for richer configs.
  • Value depth: up to 8 levels of nested objects / arrays.
  • Cache TTL: ~60 seconds per session; ETag revalidation on next fetch.

Reference

On this page