_scripts/push-env-to-vercel.md# Push Environment Variables to VercelPush environment variables from `.env.production` to your Vercel project using the Vercel REST API. Variables are stored as encrypted secrets.**Tier:** Free**File:** `_scripts/push-env-to-vercel.sh`---## Prerequisites- **Vercel CLI** installed globally: `npm i -g vercel`- **Vercel project linked** (the script will prompt you to link if not already done)- **Vercel API token** (get one from [vercel.com/account/tokens](https://vercel.com/account/tokens))## Usage### Push to production only (default)```bashnpm run env```### Push to production environment```bashnpm run env:prod```### Push to preview environment```bashnpm run env:prev```### Push to multiple environments```bash./_scripts/push-env-to-vercel.sh "preview,production"```## How It Works1. Reads variables from `.env.production`2. Links to your Vercel project (if not already linked)3. Validates your Vercel token4. Upserts each variable as an encrypted secret via the Vercel API5. Saves your token to `.vercel/project.json` for future use## First RunOn first run, the script will:1. Prompt you to run `vercel link` to connect to your project2. Ask for your Vercel API token3. Validate the token before saving it## Environment File FormatThe script reads from `.env.production`:```bash# Comments are ignoredNEXT_PUBLIC_SITE_URL=https://yourdomain.comMAILGUN_API_KEY=your-api-key-here```## Troubleshooting### "Vercel CLI not found"Install the Vercel CLI globally:```bashnpm i -g vercel```### "Unauthorized" or "Forbidden"Your Vercel token is invalid or lacks permissions. Generate a new token at [vercel.com/account/tokens](https://vercel.com/account/tokens).### "Environment file not found"Create a `.env.production` file in your project root. You can copy from `.env.production.sample`:```bashcp .env.production.sample .env.production```Then fill in your real values.