A React-based weather forecast application that provides current weather conditions and a 5-day forecast for cities worldwide.
- Search for weather information by city name
- Display current weather conditions including temperature and weather description
- Show a 5-day forecast
- Toggle between Celsius and Fahrenheit
- Responsive design for various screen sizes
- React
- TypeScript
- Vite
- country-state-city library for city data
- WeatherAPI for weather data
- Unzip the project folder
After downloading the project ZIP file, unzip it to your desired location.
-
Navigate to the project directory:
cd weather-forecast-app
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and add your WeatherAPI key:VITE_API_KEY=your_weatherapi_key_here
-
Start the development server:
npm run dev
-
Open your browser and visit
http://localhost:5173
to view the app.
-
The app uses the
WeatherContext
to manage global state, including the selected city, weather details, and forecast data. -
When a user searches for a city, the
SearchInputBox
component updates the city in the context. -
The
WeatherProvider
listens for changes to the city and fetches new weather data from the WeatherAPI. -
Current weather conditions are displayed in the
WeatherDisplay
component. -
The 5-day forecast is shown in the
ForecastLayout
component. -
Users can toggle between Celsius and Fahrenheit using a button in the UI.
Check the demo of the app here: https://jam.dev/c/3c268f33-c5f7-45cc-bf1b-5b5a8c7413f2