A modern, responsive weather application built with React, Tailwind CSS, and OpenWeatherMap API. Users can view current weather and a 5-timepoint forecast based on their location or any searched city around the world.
- 🌍 Detects your current location automatically (with permission)
- 🔍 Search for weather by city name
- 📅 Displays current weather with full details (temp, humidity, pressure, etc.)
- 🌤️ Shows weather icon and description
- 🕒 Forecast with accurate local time conversion
- 🎨 Fully responsive UI with Tailwind CSS
- ⚡ Cached weather data using React Query for performance
- React
- React Query (TanStack Query)
- Tailwind CSS
- OpenWeatherMap API
- React Icons
- Vite
git clone https://github.com/soksreng/weather-forecast-react.git
cd weather-forecast-appnpm installCreate a .env file in the root directory and add:
VITE_API_KEY=your_openweathermap_api_keyGet your API key from https://openweathermap.org/api
npm run devOpen http://localhost:5173 to view it in the browser.
src/
├── components/
│ ├── WeatherCard.jsx # UI for current weather
│ ├── Forecast.jsx # Forecast component
├── hooks/
│ ├── useGeolocation.js # Hook to get user's coordinates
│ ├── useFetchWeather.js # Fetch weather using API
├── services/
│ ├── api.js # API calls for current & forecast weather
├── utils/
│ ├── index.js # Date formatting util
├── App.jsx
├── main.jsx
- Tokyo
If the city is not found, the app displays:
“This place does not exist.”
Built by Sok Sreng CHAN
Feel free to connect or fork the repo.

