A beautiful and responsive weather application built with React and Vite
π Live Demo β Try it now!
- π Global Weather Search - Get weather information for any city worldwide
- π 3-Day Forecast - View current weather and 3-day forecast
- π¨ Beautiful UI - Modern, responsive design with Bootstrap
- β‘ Fast Performance - Built with Vite for lightning-fast development and builds
- π Smart Search - Easy-to-use city search with error handling
- π± Mobile Responsive - Looks great on all devices
- π Dynamic Backgrounds - Beautiful background layouts that enhance the experience
- Frontend Framework: React 19.1.0
- Build Tool: Vite 7.0.4
- Styling: Bootstrap 5.3.7 + Bootstrap Icons
- HTTP Client: Axios
- Date/Time: Luxon
- Alerts: SweetAlert2
- Weather API: WeatherAPI.com
- Node.js (version 16 or higher)
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/your-username/weather-app.git cd weather-app -
Install dependencies
npm install
-
Set up environment variables
Create a
.envfile in the root directory:VITE_WEATHER_API_KEY=your_weatherapi_key_here
Get your free API key from WeatherAPI.com
π For Production Deployment:
- Vercel: Add environment variables in project settings
- Netlify: Add in site settings β Environment variables
- GitHub Pages: Use GitHub Secrets in Actions
- Railway/Render: Add in dashboard environment section
-
Start the development server
npm run dev
-
Open your browser
Navigate to
http://localhost:5173to see the app running!
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build locally
npm run preview
# Run ESLint
npm run lintnpm run build# Install Vercel CLI
npm i -g vercel
# Deploy
vercel
# Add environment variable
vercel env add VITE_WEATHER_API_KEY# Install Netlify CLI
npm i -g netlify-cli
# Deploy
netlify deploy --prod --dir=dist
# Add environment variable in Netlify dashboard- Push code to GitHub
- Add
WEATHER_API_KEYto repository secrets - Enable GitHub Actions workflow
- Your app deploys automatically!
In your deployment platform dashboard, add:
- Variable Name:
VITE_WEATHER_API_KEY - Variable Value: Your WeatherAPI.com API key
.env files!
weather-app/
βββ public/ # Static assets
βββ src/
β βββ Components/ # React components
β β βββ BackgroundLayout/
β β β βββ BackgroundLayer.jsx
β β β βββ BackgroundLayer.css
β β βββ Weather/
β β β βββ Weather.jsx
β β β βββ Weather.css
β β βββ WeatherCards/
β β βββ WeatherCards.jsx
β β βββ WeatherCards.css
β βββ assets/ # Images and static files
β βββ App.jsx # Main App component
β βββ main.jsx # App entry point
β βββ index.css # Global styles
βββ package.json
βββ vite.config.js
βββ README.md
- Search for a City: Enter any city name in the search box
- View Current Weather: See current temperature, conditions, and location
- Check Forecast: View the next 3 days of weather forecast
- Error Handling: Get friendly error messages for invalid cities or network issues
- Handles API calls to WeatherAPI
- Manages search functionality
- Displays current weather information
- Shows weather forecast cards
- Displays temperature, conditions, and dates
- Responsive card layout
- Provides beautiful background layouts
- Enhances visual appeal
| Variable | Description | Required |
|---|---|---|
VITE_WEATHER_API_KEY |
Your WeatherAPI.com API key | Yes |
This app uses the WeatherAPI.com service:
- Endpoint:
https://api.weatherapi.com/v1/forecast.json - Features: Current weather + 3-day forecast
- Rate Limit: Free tier allows 1 million calls per month
- CSS files are located in each component folder
- Global styles in
src/index.css - Bootstrap classes used throughout for responsiveness
- Extend forecast days in the API call
- Add more weather details (humidity, wind speed, etc.)
- Implement geolocation for current location weather
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- WeatherAPI.com for providing the weather data
- React for the awesome framework
- Vite for the blazing fast build tool
- Bootstrap for the beautiful UI components
Abdelfattah A. Elnaggar - Frontend Developer
π± Mobile: +201101791968
πΌ LinkedIn: @abdelfattah-a-elnaggar
π Program: Route Frontend Diploma Student
Project Link: https://github.com/your-username/weather-app
Made with β€οΈ by Abdelfattah
Part of Route Frontend Diploma Program
