A React-based Weather Forecast App that allows users to view the current weather and a 5-day forecast for any city. The app also includes features like temperature unit conversion (Celsius/Fahrenheit) and a custom-built city search dropdown.
- Current Weather Display: Shows weather information like temperature, humidity, wind speed, and pressure for a default city (e.g., New Delhi).
- City Search: Allows users to search for any city using a custom dropdown search box, with real-time weather data fetched from OpenWeather API.
- 5-Day Forecast: Displays a 5-day weather forecast with high/low temperatures, weather conditions, and an icon representing the forecast.
- Temperature Unit Conversion: Switch between Celsius and Fahrenheit with a simple toggle button.
- Responsive Design: Ensures the app looks great on all devices, from mobile to desktop## Screenshots
To run this project locally, follow these steps:
Ensure you have the following installed:
- Node.js (version 12 or higher)
- npm (usually comes with Node.js)
-
Clone the repository:
git clone https://github.com/ritik7739/weather-forecast-app.git
-
Navigate to the project directory:
cd weather-forecast-app
-
Install dependencies:
Run the following command to install the required packages:
npm install
-
Set up the API Key:
You'll need an API key from OpenWeatherMap. Once you have the key, create a
.env
file in the root of the project with the following content:appId=your_openweather_api_key
-
Start the app:
Run the following command to start the development server:
npm start
-
Open the app in the browser:
Once the server is running, open your browser and visit:
http://localhost:5173
- Search for a City: Use the search box to enter the name of a city and view its current weather conditions.
- View 5-Day Forecast: Scroll down to view the 5-day weather forecast for the selected city.
- Toggle Temperature Unit: Switch between Celsius and Fahrenheit by clicking the toggle button in the app.
- React.js: For building the user interface.
- Redux: For state management.
- CSS: For styling the app.
- OpenWeatherMap API: For fetching weather data.
- CityDropdown: A custom-built dropdown to search for and select a city.
- CurrentWeather: Displays the current weather data including city name, temperature, humidity, etc.
- ForecastCard: Reusable component for showing individual day forecasts.
- TemperatureToggle: Switches between Celsius and Fahrenheit.
The app uses the OpenWeatherMap API to fetch real-time weather data. Ensure you sign up for an API key and add it to your environment variables as described above.
- Dark mode for improved user experience at night.
- Ability to add favorite cities for quick weather checks.
- Display additional weather metrics (e.g., UV index, visibility).
If you would like to contribute to this project, feel free to fork the repository and create a pull request. Contributions are always welcome!
This project is licensed under the MIT License - see the LICENSE file for details.