Skip to content
Back to skills

Deploy Vercel

BSecurity

How a Next.js front is deployed on Vercel — one project per long-lived environment, production branch and previews, function region, the clean install pnpm 11 can fail, env vars per environment, custom domains with Cloudflare as DNS only, gating a staging site, and the Hobby-plan limits. Use when creating or changing a Vercel project, its env vars or domains.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 20, 2026
developmentnextjsnodegitapibackend

Works with

  • api

Security analysis

B84/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned November 20, 2026

npx -y skills add maximlukyanovich/agent-tools --skill deploy-vercel --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Deploy Vercel?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Deploy Vercel
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/maximlukyanovich-deploy-vercel/badge)](https://www.skillsdirectory.com/skills/maximlukyanovich-deploy-vercel)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: deploy-vercel
description: How a Next.js front is deployed on Vercel — one project per long-lived environment, production branch and previews, function region, the clean install pnpm 11 can fail, env vars per environment, custom domains with Cloudflare as DNS only, gating a staging site, and the Hobby-plan limits. Use when creating or changing a Vercel project, its env vars or domains.
license: MIT
metadata:
  author: Maxim Lukyanovich
  source: https://github.com/maximlukyanovich/agent-tools
---

# deploy-vercel

## Projects and branches

- **One Vercel project for staging and production** (the Hobby way; Custom Environments are Pro):
  - **Production Branch = `main`**, set right after import — Vercel picks the repository's default
    branch (often `develop`) otherwise;
  - **staging is a Preview deployment of the `staging` branch**, with its own domain assigned to that
    Git branch (`staging.example.com` → Git Branch `staging`);
  - pull requests get previews in the same project and use the Preview env vars too.
- **The project needs a first deploy before a branch domain resolves.** A branch created before the
  project has no deployment until something is pushed or "Create Deployment" is run with its name.
- **Remove the automatic `<project>.vercel.app` production domain** when the project has its own
  domains. Per-deployment URLs stay; they are covered by the app's own gate and noindex header.
- **Production is gated and noindex until launch**: Production env gets only the gate and
  `ALLOW_INDEXING=false`, so a push to `main` cannot expose anything.
- **Function region `fra1`** in `vercel.json` (`{"regions": ["fra1"]}`) when the backend and the
  users are in Europe. The default is `iad1`: every server-side call would cross the Atlantic, and
  personal data would leave the EU.

## Install

- **Every deploy installs from scratch.** Under pnpm 11 a dependency's build script — direct or
  transitive — that is missing from `allowBuilds` in `pnpm-workspace.yaml` fails that install with
  `ERR_PNPM_IGNORED_BUILDS`. `pnpm add` and every local install of a dependency the tree has not built
  fail the same way; a built one fails once and passes when repeated, so a warm tree proves nothing: past
  `pnpm add`, without a clean install in CI on a pull request, the deploy is the first place the gap surfaces.
- **Without that CI, prove a new dependency in a fresh clone** with `pnpm install --frozen-lockfile`.
  Each `allowBuilds` entry carries its reason; `false` fits a package that ships its binary as a
  per-platform package (`esbuild`), `true` one whose script really builds something.

## Env vars

- **Set per environment** (Production / Preview) in the project, never in git. The project keeps a
  documented `.env.example`.
- **`NEXT_PUBLIC_*` are inlined at build time.** Changing one needs a redeploy, not a restart.
- **Indexing is an explicit flag** (e.g. `NEXT_PUBLIC_ALLOW_INDEXING=true` only in production).
  Everything else serves `noindex` and a disallowing `robots.txt`.
- **A front that proxies the API server-side** (`/api/*` route handlers forwarding cookies) needs only
  the API's base URL. The browser never calls the API host, so CORS and cookie domains stay out of it.

## Domains

- The domain is added in the project, and the DNS record points at Vercel (`CNAME
  cname.vercel-dns.com` for a subdomain, Vercel's `A` for an apex).
- **Behind Cloudflare, Vercel records are DNS only** (grey cloud). Proxying Vercel through Cloudflare
  is CDN-over-CDN, and it breaks Vercel's certificate issuance and verification.
- **`www` → apex redirect** is set in the Vercel domain settings.

## Gating a staging site

The Hobby plan cannot password-protect a custom domain, so staging is gated in the app:
- **basic auth in the proxy/middleware** (Next 16 `proxy.ts`, Node runtime): a list of users as JSON in
  one env var (`{"user":"password",…}`), so each person is added or removed on their own. It is off
  when the variable is absent;
- **the gate covers `/api/*` too** (include it in the matcher and skip only i18n for it). Otherwise the
  API proxy stays open behind the password page;
- **Vercel Authentication (Deployment Protection) off**: with it on, branch domains ask for a Vercel
  login of the team, and testers outside the team cannot get in;
- **an `X-Robots-Tag: noindex, nofollow` header** from `next.config` `headers()` while indexing is off,
  on top of robots.txt and the page metadata.

## Plan limits

Hobby is for non-commercial use only. A project that takes money moves to Pro before production opens.
Check the function duration limit against the slowest proxied request (set `maxDuration` on that route
handler).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.