Flags SDK Workshop

Edge Config

  • stores arbitrary JSON data
  • active global replication
  • built specifically for feature flags
  • high read volume, seldom updates
  • edit using the dashboard or programmatically

edge config

Do not make these changes, this is just for educational purposes.

flags.ts
import { flag } from "flags/next";
import { get } from "@vercel/edge-config";

export const enableSummerSale = flag<boolean>({
  key: "summer-sale",
  async decide () {
    const flags = await get("flags");
    return flags.sale;
  }
});

edge network

edge config latency

Edge Config adapter

flags.ts
import { flag } from 'flags/next';
import { edgeConfigAdapter } from '@flags-sdk/edge-config';
 
export const exampleFlag = flag({
  // Will load the `flags` key from Edge Config
  adapter: edgeConfigAdapter(),
  // Will get the `example-flag` key from the `flags` object
  key: 'example-flag',
});

Learn more

Flag Provider

The Flags SDK integrates with many different flag providers, some of which an also sync their data into Edge Config and bootstrap the configuration from there.

flags.ts
import { flag } from "flags/next";
import { statsigAdapter } from '@flags-sdk/statsig';

export const enableSummerSale = flag<boolean>({
  key: "summer-sale",
  adapter: statsigAdapter.featureGate((gate) => gate.value)
});

Learn more