To add environment variables in the Vercel Dashboard:
- Go to the Vercel Dashboard and sign in.
- Select your project.
- Click the Settings tab.
- In the left sidebar, click Environment Variables.
- Click Add New (or Create New).
- Fill in:
- Name: The environment variable name (e.g.,
DATABASE_URL, OPENAI_API_KEY)
- Value: The secret or value
- Environment: Choose where it should be available:
- Production
- Preview
- Development
- Click Save.
If you've already deployed your app, redeploy it so the new environment variables are picked up by your deployment.
Example
If your app needs an API key:
- Name:
OPENAI_API_KEY
- Value:
sk-...
- Environment: Production, Preview, Development (select the ones you need)
Verify it's working
In a Node.js app, you can access it with:
process.env.OPENAI_API_KEY
In a Next.js app:
For more details, see the official Vercel Environment Variables documentation.
If you're using a specific framework (Next.js, React/Vite, Nuxt, SvelteKit, etc.), I can also explain any framework-specific requirements.