Skip to content
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Passport
  • Connect
  • eve
Core Platform
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • Workflows
  • CI/CD
Tools
  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Open Source
  • Domains↗
  • v0↗
Learn
  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base
Build
  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
Explore
  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community↗
EnterprisePricing
Contact
Log InSign Up
Dashboard

Products
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Passport
  • Connect
  • eve
Core Platform
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • Workflows
  • CI/CD
Tools
  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Open Source
  • Domains↗
  • v0↗
Resources
Learn
  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base
Build
  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
Explore
  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community↗
Enterprise
Pricing
Sign UpLog In
Contact

Flags SDK with Statsig

A Next.js example that uses Flags SDK and Statsig to change a greeting and show or hide a banner.

DeployView Demo

Flags SDK with Statsig

Use the Flags SDK (software development kit) with Statsig in a Next.js application. Feature flags are settings that change application behavior. The server evaluates two flags: welcome_message_text controls a greeting, and show_banner shows or hides a banner.

View the demo.

Deploy this template

The Deploy button copies the statsig example folder and installs published SDK packages.

Setup

Install the Statsig integration, or use an existing Statsig project.

Create these settings in Statsig:

KeyTypeConfiguration
welcome_message_textDynamic ConfigSet the default value to { "text": "Welcome to the Statsig example" }.
show_bannerFeature GateAdd a rule that passes for everyone (100%).

A Dynamic Config stores values such as the greeting text. A Feature Gate supplies a boolean value that shows or hides the banner.

Copy .env.example to .env.local and set:

  • STATSIG_SERVER_API_KEY: your Statsig server secret key.
  • FLAGS_SECRET: generate this value with the command below.

For a linked Vercel project, use vercel env pull .env.local to get its environment variables.

You can enable Global Config Syncing in the integration. Set EXPERIMENTATION_CONFIG and EXPERIMENTATION_CONFIG_ITEM_KEY to use that configuration.

Change the config or gate in Statsig. Refresh the page after the SDK or Global Config has updated.

Generate FLAGS_SECRET from 32 random bytes, encoded as Base64url. Base64url is an encoding that uses URL-safe characters.

node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))"

Use the same FLAGS_SECRET in .env.local and the matching Vercel project environment. For Development, add it as a regular environment variable (Config).

Run locally

Node.js 22 or newer is recommended. From the copied example folder, run:

pnpm install
pnpm dev

Open http://localhost:3000.

For a production build, run:

pnpm build
pnpm start

Try the flags

Every visitor uses the same demo-user identity. Change identify in flags.ts to add user targeting. User targeting selects flag values for specific users.

Flags Explorer

Flags Explorer is the Vercel Toolbar tool for temporary flag values. The example exposes flag definitions at /.well-known/vercel/flags. FLAGS_SECRET protects this endpoint, which is the URL that supplies flag information. Link the example folder with vercel link and sign in to the toolbar. Restart the development server after linking.

Open Flags Explorer to change the greeting or banner for your session. These temporary values do not change the provider configuration. The example reports evaluated values to the toolbar.

For preview deployments, enable the Vercel Toolbar in project settings. Set the provider credentials and a matching FLAGS_SECRET for that environment.

See the Flags Explorer documentation for more information.

For development inside the Flags SDK repository, see the example README.

GitHub
Ownervercel
Repositoryflags
LicenseView License
Use Cases
Edge Config
Stack
Next.js
Tailwind
Experimentation
Statsig

Related Templates

Experimentation with Statsig

Reduce CLS and improve performance from client-loaded experiments with Statsig
Experimentation with Statsig thumbnail

A/B Testing Simple

By A/B testing at the edge, you'll reduce CLS from client-loaded experiments and improve your site's performance with smaller JS bundles.
A/B Testing Simple thumbnail

Related Integrations

Statsig

Performant Feature Flags, Experiments, Analytics, and Log Drains

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • ConnectNew
  • PassportNew
  • eveNew

Core Platform

  • CI/CD
  • Content Delivery
  • Fluid Compute
  • Observability

Security

  • Platform Security
  • WAF
  • Bot Management
  • BotID

Tools

  • Vercel Drop
  • Vercel Agent
  • Vercel Plugin
  • Agent Skills
  • Domains
  • v0

Frameworks

  • eveNew
  • Next.js
  • Nuxt
  • SvelteKit
  • Nitro
  • Turborepo
  • Tanstack Start
  • FastAPI
  • All frameworks

SDKs

  • Vercel SDK
  • Workflow SDK
  • Flags SDK
  • Chat SDK
  • Queues SDK
  • Streamdown

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
  • Platform Engineers
  • Design Engineers

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Articles
  • Community
  • Is Agentic

Explore

  • Customers
  • Marketplace
  • Templates
  • Partner Finder
  • Vercel + AWS

Company

  • About
  • Careers
  • Press
  • Events
  • Startups
  • Shipped on Vercel
  • Open Source Program
  • Enterprise
  • Pricing
  • Help

Legal & Trust

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • DPA
  • Acceptable Use Policy
  • Legal (all documents)
  • Trust Center
  • Status

Social

  • GitHub
  • X
  • LinkedIn
  • YouTube
  • Instagram
  • VercelVercel
DeployView Demo

Loading status…

Select a display theme: