Skip to main content
Zee Academy · Lesson 08 · Deploying and Automating with Vercel

Environment Variables and Connecting a Domain on Vercel

Learn how to store API keys safely and connect your own domain without downtime.

Next lesson

What you will learn

  • Never write API keys directly into your code. Use the Environment Variables section in Vercel.
  • Use different values for Production and Preview: for example, a Stripe test key for branches and the live key only for main.
  • Connecting a domain in Vercel: Settings -> Domains -> enter the domain name and follow the instructions for the A and CNAME records.

Adding your own domain in the Vercel dashboard

Enter your domain (e.g. firma.com). Vercel will suggest adding the www.firma.com version too, with an automatic 301 redirect for SEO.

Step by step

  1. Pull production environment variables into your local setup

    vercel env pull .env.local

    Downloads the project's secret keys from Vercel into your local .env.local file.

Tip from practice

Always choose "Redirect www.firma.com to firma.com" (or the other way round). If both versions work separately, Google sees duplicate content and may split your ranking between them.