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 Repovercel/examples
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

Get Started

  • Templates
  • Supported frameworks
  • Marketplace
  • Domains

Build

  • Next.js on Vercel
  • Turborepo
  • v0

Scale

  • Content delivery network
  • Fluid compute
  • CI/CD
  • Observability
  • AI GatewayNew
  • Vercel AgentNew

Secure

  • Platform security
  • Web Application Firewall
  • Bot management
  • BotID
  • SandboxNew

Resources

  • Pricing
  • Customers
  • Enterprise
  • Articles
  • Startups
  • Solution partners

Learn

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

Frameworks

  • Next.js
  • Nuxt
  • Svelte
  • Nitro
  • Turbo

SDKs

  • AI SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDK
  • Streamdown AINew

Use Cases

  • Composable commerce
  • Multi-tenant platforms
  • Web apps
  • Marketing sites
  • Platform engineers
  • Design engineers

Company

  • About
  • Careers
  • Help
  • Press
  • Legal
  • Privacy Policy

Community

  • Open source program
  • Events
  • Shipped on Vercel
  • GitHub
  • LinkedIn
  • X
  • YouTube

Loading status…

Select a display theme:
    • AI Cloud
      • AI Gateway

        One endpoint, all your models

      • Sandbox

        Isolated, safe code execution

      • Vercel Agent

        An agent that knows your stack

      • AI SDK

        The AI Toolkit for TypeScript

      • v0

        Build applications with AI

    • Core Platform
      • CI/CD

        Helping teams ship 6× faster

      • Content Delivery

        Fast, scalable, and reliable

      • Fluid Compute

        Servers, in serverless form

      • Workflow

        Long-running workflows at scale

      • Observability

        Trace every step

    • Security
      • Bot Management

        Scalable bot protection

      • BotID

        Invisible CAPTCHA

      • Platform Security

        DDoS Protection, Firewall

      • Web Application Firewall

        Granular, custom protection

    • Company
      • Customers

        Trusted by the best teams

      • Blog

        The latest posts and changes

      • Changelog

        See what shipped

      • Press

        Read the latest news

      • Events

        Join us at an event

    • Learn
      • Docs

        Vercel documentation

      • Academy

        Linear courses to level up

      • Knowledge Base

        Find help quickly

      • Community

        Join the conversation

    • Open Source
      • Next.js

        The native Next.js platform

      • Nuxt

        The progressive web framework

      • Svelte

        The web’s efficient UI framework

      • Turborepo

        Speed with Enterprise scale

    • Use Cases
      • AI Apps

        Deploy at the speed of AI

      • Composable Commerce

        Power storefronts that convert

      • Marketing Sites

        Launch campaigns fast

      • Multi-tenant Platforms

        Scale apps with one codebase

      • Web Apps

        Ship features, not infrastructure

    • Tools
      • Marketplace

        Extend and automate workflows

      • Templates

        Jumpstart app development

      • Partner Finder

        Get help from solution partners

    • Users
      • Platform Engineers

        Automate away repetition

      • Design Engineers

        Deploy for every idea

  • Enterprise
  • Pricing
Log InContact
Sign Up
Sign Up
DeployView Demo
AI Gateway

One endpoint, all your models

Sandbox

Isolated, safe code execution

Vercel Agent

An agent that knows your stack

AI SDK

The AI Toolkit for TypeScript

v0

Build applications with AI

CI/CD

Helping teams ship 6× faster

Content Delivery

Fast, scalable, and reliable

Fluid Compute

Servers, in serverless form

Workflow

Long-running workflows at scale

Observability

Trace every step

Bot Management

Scalable bot protection

BotID

Invisible CAPTCHA

Platform Security

DDoS Protection, Firewall

Web Application Firewall

Granular, custom protection

Customers

Trusted by the best teams

Blog

The latest posts and changes

Changelog

See what shipped

Press

Read the latest news

Events

Join us at an event

Docs

Vercel documentation

Academy

Linear courses to level up

Knowledge Base

Find help quickly

Community

Join the conversation

Next.js

The native Next.js platform

Nuxt

The progressive web framework

Svelte

The web’s efficient UI framework

Turborepo

Speed with Enterprise scale

AI Apps

Deploy at the speed of AI

Composable Commerce

Power storefronts that convert

Marketing Sites

Launch campaigns fast

Multi-tenant Platforms

Scale apps with one codebase

Web Apps

Ship features, not infrastructure

Marketplace

Extend and automate workflows

Templates

Jumpstart app development

Partner Finder

Get help from solution partners

Platform Engineers

Automate away repetition

Design Engineers

Deploy for every idea