CodingNic

Get Started with the React Project

Prepare the Environment Variables

Get Started with the React Project 10 min read

Prepare the Environment Variables

Task

Prepare a local environment file for the weather-service API key.

File / section

Project root: .env.example and .gitignore

Change

Create your local environment file from the example:

text
.env.example → .env

Your .env file should contain:

env
VITE_OPENWEATHER_API_KEY=your_openweathermap_api_key_here

Do not commit .env to Git. The example file is safe to keep in the project because it contains only a placeholder.

Why this matters

The API key is needed when WeatherNow starts making real weather requests. Keeping your local value in .env also prevents you from placing your personal key directly inside the course source files.

We will add and test the actual OpenWeather request in the next module.

Test it

Confirm that .env exists locally and that .gitignore keeps it out of version control.

Checkpoint

Your local WeatherNow project is prepared to receive the weather API key.