Skip to content
VercelLogotypeVercelLogotype
LoginSign Up

Vercel Flags with Flags SDK and Next.js

An e-commerce example using static page variants with middleware rewrites determined by Flags SDK and Vercel Flags.

DeployView Demo

Vercel Flags SDK Example

This example uses Vercel Flags for feature flags with the Flags SDK along with the @flags-sdk/vercel adapter and the Flags Explorer.

Demo

https://flags-sdk-vercel.vercel.app/

How it works

This demo uses feature flags in Vercel Flags to control the visibility of banners on the page and the color of the checkout button. Flag configurations are managed directly in the Vercel Dashboard.

If you deploy your own and configure the feature flags in the Vercel Dashboard, you can also use the Flags Explorer to enable/disable the features locally.

Deploy this template

Clicking the button above will:

  1. Clone this repository to your GitHub account
  2. Create a new Vercel project
  3. Deploy immediately (even if you have not configured flags yet)

Step 1: Link the project

In order to use the Flags Explorer, you need to link the project on your local machine.

vercel link

Select the project from the list you just deployed.

Step 2: Create Feature Flags in the Vercel Dashboard

Navigate to the Flags tab in your Vercel project dashboard and create the following flags:

Feature Flags:

  • summer-sale - Boolean flag to show/hide the summer sale banner
  • free-delivery - Boolean flag to show/hide the free delivery banner
  • proceed-to-checkout-color - String flag with values: blue, green, red

You can also find the feature flag keys in the flags.ts file.

Step 3: Pull all environment variables

This pulls the FLAGS environment variable that contains your SDK keys:

vercel env pull

Step 4: Run the development server

pnpm install
pnpm dev

Deploy without configuration

If FLAGS or FLAGS_SECRET are missing, requests are rewritten to /setup until configuration is complete. The setup page includes a checklist and the required flag keys.

Local Development

For local development, make sure you have:

  1. Linked your project with vercel link
  2. Pulled environment variables with vercel env pull
  3. Set FLAGS_SECRET in .env.local for precompute and secure Flags Explorer overrides

Learn More

  • Vercel Flags Documentation
  • Flags SDK Documentation
  • Flags Explorer Documentation
GitHub
Ownervercel
Repositoryexamples
LicenseView License
Use Cases
Edge Middleware
Stack
Next.js
Tailwind

Related Templates

Flags SDK with Hypertune and Next.js

An e-commerce example built with Hypertune and Flags SDK that works well with Vercel Marketplace
Flags SDK with Hypertune and Next.js thumbnail

Statsig Experimentation with Flags SDK

Run experiments on static pages with Statsig and the Flags SDK
Statsig Experimentation with Flags SDK thumbnail

Flags SDK with OpenFeature adapter

Use OpenFeature providers with the Flags SDK
Flags SDK with OpenFeature adapter thumbnail

Agent Stack

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

Core Platform

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

Security

  • Platform Security
  • WAF
  • Bot Management
  • Bot ID

Tools

  • Vercel DropNew
  • Vercel Agent
  • Vercel PluginNew
  • Agent Skills
  • Next.js
  • Domains
  • v0

Frameworks

  • eveNew
  • Nuxt
  • SvelteKit
  • Nitro
  • Turborepo
  • Tanstack Start
  • FastAPI
  • xmcp
  • All frameworks

SDKs

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

Build

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

Learn

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

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
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • Eve
Core Platform
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • CI/CD
Tools
  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • 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
  • Workflows
  • Eve

Core Platform

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

Tools

  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • 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
DeployView Demo

Loading status…

Select a display theme: