CodingNic

Connect WeatherNow to the Weather API

Add the OpenWeather API Key

Connect WeatherNow to the Weather API 10 min read

Add the OpenWeather API Key

Task

Create and activate an OpenWeather API key.

File / section

.env and the official OpenWeather account pages

Change

Sign up at https://home.openweathermap.org/users/sign_up. Then find your key in the OpenWeather account area and place it in .env as VITE_OPENWEATHER_API_KEY=your_key_here. Read the API key guidance at https://openweathermap.org/appid.

Why this change matters

The app reads the key through import.meta.env.VITE_OPENWEATHER_API_KEY. New keys may take time to activate, so do not treat an immediate 401 as proof that your code is wrong. OpenWeather notes that activation can take up to about two hours in its API-key FAQ.

Test it

Restart Vite after changing .env.

Checkpoint

The app has access to the configured API key without hard-coding it in a component.