New advertisers: 50% off your first month with code FIRSTMONTHSee slots
vercel avatar

Flags

Step-by-step guide for wiring a new or changed Next.js experimental flag from type declaration through runtime bundles.

skills.sh installs
900
GitHub stars
143.6K
last updated
May 16, 2026
View on GitHub

What it does

  • Covers type declaration, zod schema, build-time injection, runtime env plumbing, and the choice between env-var branching and separate bundle variants
  • Lists required files: config-shared.ts, config-schema.ts, define-env.ts, next-server.ts, export/worker.ts, and module.compiled.js
  • Enforces DefinePlugin entries in next-runtime.webpack-config.js to be scoped to bundleType === 'app' so next-server.ts assignments are not replaced
  • Designed for framework contributors editing Next.js internals, with links to the dce-edge, react-vendoring, and runtime-debug skills

Install

$ npx -y skills add vercel/next.js --skill flags -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Feature Flags

Use this skill when adding or changing framework feature flags in Next.js internals.

Required Wiring

All flags need: config-shared.ts (type) → config-schema.ts (zod). If the flag is consumed in user-bundled code (client components, edge routes, app-page.ts template), also add it to define-env.ts for build-time injection. Runtime-only flags consumed exclusively in pre-compiled bundles can skip define-env.ts.

Where the Flag Is Consumed

Client/bundled code only (e.g. __NEXT_PPR in client components): define-env.ts is sufficient. Webpack/Turbopack replaces process.env.X at the user's build time.

Pre-compiled runtime bundles (e.g. code in app-render.tsx): The flag must also be set as a real process.env var at runtime, because app-render.tsx runs from pre-compiled bundles where define-env.ts doesn't reach. Two approaches:

Details

Repository
github.com/vercel/next.js
Categories
Frontend & UI Code, DevOps & Cloud
First seen
May 16, 2026

More from vercel/next.js

All 14

Similar to Flags

More Frontend & UI Code