Skip to content

Instantly share code, notes, and snippets.

@leerob
Last active July 29, 2023 06:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leerob/ca124b68ad58afe5a4c2b763cddcb60c to your computer and use it in GitHub Desktop.
Save leerob/ca124b68ad58afe5a4c2b763cddcb60c to your computer and use it in GitHub Desktop.
Vercel CLI for Multiple Environments

Multiple Evironments with Vercel CLI

  1. Install the Vercel CLI
  2. Run npx create-next-app my-app to make your new project.
  3. Run vercel link to create a new project and name it my-app-dev.
  4. Save the contents of the .vercel/project.json file.
  5. Your new project was created in your Vercel account. You can now add a custom domain in your project settings.
  6. To deploy to dev, you'll run:
VERCEL_ORG_ID=<value-from-json-file> VERCEL_PROJECT_ID=<value-from-json-file> vercel --prod --scope <username-or-team-slug>
  1. Run vercel link again to create another project for production.
➜  vercel-cli-multi-env git:(main) vercel link
Vercel CLI 21.0.1
? Set up “~/Developer/vercel-cli-multi-env”? [Y/n] y
? Which scope should contain your project? Lee Robinson
? Found project “leerob/vercel-cli-multi-env”. Link to it? [Y/n] n
? Link to different existing project? [Y/n] n
? What’s your project’s name? vercel-cli-multi-prod
? In which directory is your code located? ./
Auto-detected Project Settings (Next.js):
- Build Command: `npm run build` or `next build`
- Output Directory: Next.js default
- Development Command: next dev --port $PORT
? Want to override the settings? [y/N] n
✅  Linked to leerob/vercel-cli-multi-prod (created .vercel)
  1. Save the contents of the .vercel/project.json file.
  2. Your new project was created in your Vercel account. You can now add a custom domain in your project settings.
  3. To deploy to prod, you'll run:
VERCEL_ORG_ID=<value-from-json-file> VERCEL_PROJECT_ID=<value-from-json-file> vercel --prod --scope <username-or-team-slug>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment