Current weather for any city, or for your current location, in plain HTML, CSS and JavaScript (no build step). Data comes from the OpenWeatherMap Current Weather API.
Live demo: https://getweathernow.vercel.app/
- Search by city name (press Enter)
- "Get Device Location" uses the browser Geolocation API
- Shows temperature, "feels like", humidity and a condition icon
- °C/°F toggle (the API is always queried in metric units and converted in the browser); your choice is remembered
- Remembers the last city you searched and loads its weather automatically on your next visit
- Clear error messages for unknown cities, rejected API keys, rate limits and network failures
Serve the folder with any static server (geolocation requires https:// or localhost):
npx serve .
# or
python3 -m http.server 8000Then open the printed URL.
The OpenWeatherMap API key is hard-coded in the request URLs in script.js (appid= in requestApi and onSuccess). Because this is a static front-end app, any key shipped to the browser is visible to every visitor; it cannot be kept secret without a server-side proxy.
To use your own key:
- Create a free key at https://home.openweathermap.org/api_keys.
- Replace the
appidvalue in both URLs inscript.js. - Keep usage limits in mind and rotate the key if it is abused.
