跳到正文
cccskills
免费在 GitHub 公开

vercel-nextjs-config

Configure a Next.js app for Vercel. next.config versus vercel.json, proxy (renamed from middleware in Next.js 16), images, redirects and headers, function duration and region, caching and static export pitfalls, and local verification. Use when editing next.config, vercel.json or routing for a Next.js project on Vercel.

中文简介正在准备中。当前显示原文说明。

集成工具Vercel
查看安装方法

包含的文件(1)

  • SKILL.md5.3 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Next.js configuration on Vercel

Vercel detects Next.js and builds it with no configuration. Add configuration only for a reason you can name. First read: package.json (next version), the existing next.config.*, and vercel.json if present. Version matters: check https://nextjs.org/docs and https://vercel.com/docs (append .md to a Vercel docs URL for plain text) before relying on memory for anything below.

Where each setting lives

SettingPut it inWhy
Redirects, rewrites, headers for the app's routesnext.config.ts (redirects(), rewrites(), headers())version-controlled with the app, works in next dev
Platform behavior: crons, regions, per-function memory/maxDuration, ignoreCommand, buildCommand/installCommand, outputDirectoryvercel.json (or vercel.ts)Vercel-only features
Secrets and per-environment valuesVercel environment variables (vercel-env-vars)never in either file
Project name, Node version, root directory, Git settingsProject Settingsdashboard-only

Do not define the same redirect in both files. Only one of vercel.json, vercel.toml and vercel.ts may exist. A vercel.json that mixes legacy routes with rewrites/redirects/headers is rejected.

A sensible next.config.ts

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  images: {
    // Allow only the hosts you serve images from.
    remotePatterns: [{ protocol: "https", hostname: "images.example.com", pathname: "/**" }],
  },
  async redirects() {
    return [{ source: "/old", destination: "/new", permanent: true }];
  },
  async headers() {
    return [{ source: "/(.*)", headers: [{ key: "X-Content-Type-Options", value: "nosniff" }] }];
  },
};

export default nextConfig;
  • output: "standalone" is for self-hosting in a container. It is not needed on Vercel.
  • output: "export" produces a static site. Redirects, rewrites, headers and server features (proxy, route handlers that read the request, ISR) do not run in a static export; define redirects and headers in vercel.json instead, or do not export.
  • Do not set typescript.ignoreBuildErrors or eslint.ignoreDuringBuilds to make a deploy pass; fix the errors or tell the user they are being skipped.
  • images.remotePatterns is an allow list: a wildcard host lets anyone use your image optimizer as a proxy and increases cost.

Proxy (formerly middleware)

Next.js 16 renamed the middleware file convention to proxy (proxy.ts at the project root or in src/, exporting proxy); the Node.js runtime is the default and a runtime export is not allowed there. Migrate with npx @next/codemod@canary middleware-to-proxy . (show the diff first).

  • Without a matcher, it runs on every request including _next/static, images and public/ files. Exclude them or auth logic will break CSS and JS: matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"].
  • Server Functions are POSTs to the page route; a matcher that skips the page also skips them. Check authorization inside each Server Function, not only in proxy.
  • It does not work with output: "export".

Environment variables in Next.js

  • NEXT_PUBLIC_* values are inlined into the browser bundle at build time. Never use that prefix for a secret. Changing one needs a rebuild.
  • Server-only variables are read from process.env in Server Components, Route Handlers and Server Functions only.
  • .env.local is for local development and must be gitignored. Use vercel env pull / vercel env run for team values.

Functions, caching and rendering

  • Per-route duration: export const maxDuration = 30; in the route segment, or functions in vercel.json. Limits depend on plan; check the docs.
  • Regions: regions in vercel.json; put functions near the database.
  • Next.js 16 Cache Components (cacheComponents: true) makes data dynamic by default and caches with the use cache directive; do not enable it in an existing app without reading the migration guide and running the build.
  • ISR: fetch(url, { next: { revalidate: 60 } }) or export const revalidate.
  • export const dynamic = "force-dynamic" on a page that could be static costs money and speed; use it only when needed.

Verify locally before any deploy

  1. npm run build (or the project's build) must pass with no skipped checks.
  2. npx vercel build after vercel pull reproduces Vercel's build; it needs the user's login for pull.
  3. Run the production build locally (next start) and request the routes you changed, including a redirect, a header, and a proxy-protected path.
  4. Run /vercel-preflight.
  5. Deploying is a separate step: follow vercel-deploy, preview first, with the user's approval.

Done means

You report the commands you ran and what they printed (build success, status codes of the routes you requested), what you changed in which file and why, and anything you could not verify without a deployment.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Audit a page or UI against WCAG 2.2 AA. Runs a static HTML scanner and a contrast calculator, then walks the manual keyboard, zoom, screen-reader-name and form checks the tools cannot do, and reports findings with the criterion, evidence, fix and how to verify. Use for accessibility reviews, WCAG checks, contrast questions or "is this accessible".

中文简介正在准备中。当前显示原文说明。

codewhale-hq/codewhale-plugin-marketplace52026年10月21日 更新

batch

免费

Break a large, parallelizable goal into bounded work units, coordinate existing agent/worktree machinery, integrate, and verify. Explicit-only.

中文简介正在准备中。当前显示原文说明。

codewhale-hq/codewhale-plugin-marketplace52026年10月21日 更新

best-of-n

免费

Generate a small set of independent candidate solutions in worktrees, judge them against one explicit rubric, and apply the winner only after PASS verification.

中文简介正在准备中。当前显示原文说明。

codewhale-hq/codewhale-plugin-marketplace52026年10月21日 更新

Read and act on selected Chrome tabs and frames — their real browser, their logged-in sessions. Use for questions about the current page, filling a form the user is on, following a link they mentioned, or checking what a site actually renders. Not for throwaway automation in a clean profile.

中文简介正在准备中。当前显示原文说明。

codewhale-hq/codewhale-plugin-marketplace52026年10月21日 更新

Deploy or change a Cloudflare Worker with cf. Review config, preflight, build and dry-run; show the target and change, obtain explicit approval, deploy and verify. Covers versions, secrets, rollback and named modes.

中文简介正在准备中。当前显示原文说明。

codewhale-hq/codewhale-plugin-marketplace52026年10月21日 更新

Look up current Cloudflare documentation (Workers, Pages, KV, R2, D1, Queues, DNS, WAF, platform APIs) through Cloudflare's official remote MCP server. Use when answering Cloudflare questions or writing Cloudflare config.

中文简介正在准备中。当前显示原文说明。

codewhale-hq/codewhale-plugin-marketplace52026年10月21日 更新

查看 codewhale-hq 的全部技能

报告此技能的问题