flags

Implement Next.js experimental feature flags across config and runtime files.

142k|31.7k|Updated Oct 5, 2016
One-click install
npx skills add https://github.com/vercel/next.js --skill flags-vercel
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flags
Source: https://github.com/vercel/next.js/tree/main/.agents/skills/flags
Command: npx skills add https://github.com/vercel/next.js --skill flags-vercel

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps engineers add or modify Next.js experimental feature flags across core configuration and runtime wiring, ensuring flags are defined, validated, and applied consistently across builds and runtime environments.

Core Features & Use Cases

  • Guides proper wiring across config-shared.ts, config-schema.ts, and define-env.ts to enable or expose flags.
  • Explains deployment paths for runtime flags in next-server.ts and export/worker.ts, including decisions between runtime env vars and separate bundles.
  • Covers how to apply flags in client and server runtimes and how to test in development and production builds.

Quick Start

Identify the feature flag you want to enable or modify and apply the required wiring across the configuration and runtime files.

Frequently Asked Questions about flags

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a Next.js experimental feature flag end-to-end?

To add a Next.js experimental feature flag, you wire it across config-shared.ts for type declarations, config-schema.ts for zod validation, and define-env.ts for build-time injection, ensuring consistency across runtime layers.

What's the best way to expose Next.js feature flags at build time vs runtime?

Exposing Next.js feature flags requires injecting them via define-env.ts at build time, while runtime flags are plumbed through next-server.ts and export/worker.ts to decide between using runtime environment variables or generating separate server bundles.

Can I use a zod schema to validate Next.js configuration changes?

Yes, you can validate Next.js configuration changes by defining the feature flag schema within config-schema.ts, which ensures type safety and validates experimental flags before they influence build-time or runtime behavior.

Why are my Next.js feature flags not applying in the production build?

Next.js feature flags may fail in production builds if they lack proper runtime env plumbing across server bundles, requiring correct wiring in next-server.ts and module.compiled.js to ensure build-time injections propagate correctly.

Do I need separate bundles to deploy Next.js runtime feature flags?

Deploying Next.js runtime feature flags requires deciding between reading runtime environment variables in next-server.ts or creating separate bundles in export/worker.ts, depending on whether the flag influences build-time or runtime behavior.

When should I modify define-env.ts for Next.js configuration flags?

You should modify define-env.ts when you need to inject Next.js configuration flags at build time, ensuring the experimental features are properly compiled into the client and server runtimes during the build process.