npx skills add https://github.com/vercel/next.js --skill flags在 Next.js 内部添加或更改框架功能标志时使用此技能。
所有标志都需要:config-shared.ts(类型)→ config-schema.ts(zod)。如果标志在用户打包的代码中使用(客户端组件、边缘路由、app-page.ts 模板),还需将其添加到 define-env.ts 以进行构建时注入。仅在预编译包中使用的运行时标志可以跳过 define-env.ts。
仅限客户端/打包代码(例如客户端组件中的 __NEXT_PPR):define-env.ts 就足够了。Webpack/Turbopack 会在用户构建时替换 process.env.X。
预编译运行时包(例如 中的代码):该标志还必须在运行时设置为真实的 变量,因为 从预编译包运行,而 无法到达这些包。有两种方法:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
app-render.tsxprocess.envapp-render.tsxdefine-env.tsnext-server.ts + export/worker.ts 中设置。两条代码路径都保留在一个包中。简单但会增加包大小。next-runtime.webpack-config.js 中添加 DefinePlugin 条目(限定于 bundleType === 'app'),添加新的 taskfile 任务,更新 module.compiled.js 选择器,并且仍然在 next-server.ts + export/worker.ts 中设置环境变量以进行包选择。消除了死代码但增加了构建复杂性。对于运行时标志,还需将字段添加到 config-shared.ts 中的 NextConfigRuntime Pick 类型。
next-runtime.webpack-config.js(rspack)通过 taskfile.js 包任务构建。src/server/route-modules/app-page/module.compiled.js 中根据 process.env 变量进行。{turbo/webpack} × {experimental/stable/nodestreams/experimental-nodestreams} × {dev/prod} = 每种路由类型最多 16 个包。define-env.ts 影响用户打包,不影响预编译的运行时内部。app-render.tsx 中的 process.env.X 检查要么在运行时包构建时被 DefinePlugin 替换,要么在服务器启动时作为实际环境变量读取。它们不受用户来自 define-env.ts 的定义影响。next-runtime.webpack-config.js 中的 DefinePlugin 条目必须限定在正确的 bundleType(例如仅限 app,而非 server),以避免替换 next-server.ts 中的赋值目标。$dce-edge - DCE 安全的 require 模式和边缘约束$react-vendoring - 入口基础边界和打包的 React$runtime-debug - 复现和验证工作流每周安装量
311
仓库
GitHub 星标
138.5K
首次出现
2026年2月17日
安全审计
安装于
gemini-cli298
opencode297
codex297
github-copilot296
kimi-cli294
amp293
Use this skill when adding or changing framework feature flags in Next.js internals.
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.
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:
next-server.ts + export/worker.ts. Both code paths stay in one bundle. Simple but increases bundle size.next-runtime.webpack-config.js (scoped to bundleType === 'app'), new taskfile tasks, update module.compiled.js selector, and still set env var in next-server.ts + export/worker.ts for bundle selection. Eliminates dead code but adds build complexity.For runtime flags, also add the field to the NextConfigRuntime Pick type in config-shared.ts.
next-runtime.webpack-config.js (rspack) via taskfile.js bundle tasks.src/server/route-modules/app-page/module.compiled.js based on process.env vars.{turbo/webpack} × {experimental/stable/nodestreams/experimental-nodestreams} × {dev/prod} = up to 16 bundles per route type.define-env.ts affects user bundling, not pre-compiled runtime internals.process.env.X checks in app-render.tsx are either replaced by DefinePlugin at runtime-bundle-build time, or read as actual env vars at server startup. They are NOT affected by the user's defines from define-env.ts.$dce-edge - DCE-safe require patterns and edge constraints$react-vendoring - entry-base boundaries and vendored React$runtime-debug - reproduction and verification workflowWeekly Installs
311
Repository
GitHub Stars
138.5K
First Seen
Feb 17, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli298
opencode297
codex297
github-copilot296
kimi-cli294
amp293
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
68,100 周安装
竞争对手研究指南:SEO、内容、反向链接与定价分析工具
231 周安装
Azure 工作负载自动升级评估工具 - 支持 Functions、App Service 计划与 SKU 迁移
231 周安装
Kaizen持续改进方法论:软件开发中的渐进式优化与防错设计实践指南
231 周安装
软件UI/UX设计指南:以用户为中心的设计原则、WCAG可访问性与平台规范
231 周安装
Apify 网络爬虫和自动化平台 - 无需编码抓取亚马逊、谷歌、领英等网站数据
231 周安装
llama.cpp 中文指南:纯 C/C++ LLM 推理,CPU/非 NVIDIA 硬件优化部署
231 周安装
next-runtime.webpack-config.js must be scoped to the correct bundleType (e.g. app only, not server) to avoid replacing assignment targets in next-server.ts.