Development, Preview and Production Environments

A big thing in development is setting up different environments so that when you are developing you do not accidentally make breaking changes to the production application.

In this lesson, I am going to show you how environment variables work with Vercel and Next.js.

I mostly use them to connect to my database. I typically use Firebase, which is in the cloud. Because of this, they supply a set of strings that allow you to make a connection with their services. Vercel’s environment variables allow me to connect to separate databases for development, feature, and production environments.

I am not actually going to hook up a database in this lesson, but I’ll show you how to do it. You can use environment variables for all sorts of things, but this is a common use case.

Set up the development environment Variables

First step is to create a file with the name of .env.local.

Get hands-on with 1200+ tech skills courses.