A modern, responsive React weather application that displays real-time weather information using the Met Office DataHub API. Built with React, Vite, and Tailwind CSS.
- π€οΈ Real-time weather data from the Met Office API
- π Automatic geolocation detection
- π± Responsive design for all devices
- π Dynamic weather icons and conditions
- π Detailed weather metrics (UV index, humidity, pressure, etc.)
- β° 24-hour hourly forecast
- π 3-day daily forecast
- π¨ Beautiful gradient UI with glassmorphism effects
- Demo
- Prerequisites
- Installation
- Configuration
- Usage
- Project Structure
- API Documentation
- Development
- Deployment
- Contributing
- License
Visit the live demo: Weather App Demo
Before you begin, ensure you have the following installed:
- Node.js (version 18.0 or higher)
- npm (version 8.0 or higher)
- Met Office DataHub API Key (see Configuration)
If you have the GitHub CLI installed, you can fork and clone the repository in one command:
gh repo fork https://github.com/rigsnv/weather-app.git --cloneGitHub CLI docs: https://cli.github.com/manual/gh_repo_fork
You can fork the repo via GitHub's website and doenload it there to, or runnig this command.
git clone https://github.com/[your-github]/weather-app.gitcd weather-app
npm install- Visit Met Office DataHub
- Register for a free account
- Create a new application to get your API key
- Note your API key and base URL
-
Copy the environment template:
cp .env.example .env
-
Edit the
.envfile with your credentials:VITE_MET_OFFICE_API_KEY=your_api_key_here VITE_DEV_API_BASE_URL=https://data.hub.api.metoffice.gov.uk/sitespecific/v0/point/ VITE_PROD_API_BASE_URL=your_production_backend_url
| Variable | Description | Required | Example |
|---|---|---|---|
VITE_MET_OFFICE_API_KEY |
Your Met Office API key | Yes | hjJ5GVZ... |
VITE_DEV_API_BASE_URL |
Met Office API base URL for development | Yes | https://data.hub.api.metoffice.gov.uk/sitespecific/v0/point/ |
VITE_PROD_API_BASE_URL |
Your backend API URL for production | No | https://your-api.com |
Start the development server:
npm run devThe application will be available at http://localhost:5173
Build the application for production:
npm run buildThis command will create a new folder named "dist" in the root folder of your app, bundle the app and place it in this folder.
npm run previewThis command will serve from the dist folder and use your production settings, includding serving from your back end, rahter than directly calling the Met Office API and exposing your API key to the front end code as in development mode.
For more information about building for production and the different options, visit: https://vite.dev/guide/build.html
Run ESLint to check code quality:
npm run lintweather-app/
βββ public/
β βββ cloud-sun.svg # App favicon
β βββ vite.svg
βββ src/
β βββ components/ # React components
β β βββ ui/ # Reusable UI components
β β β βββ WeatherCard.jsx
β β β βββ WeatherIcon.jsx
β β βββ CurrentWeather.jsx # Main weather display
β β βββ DailyForecast.jsx # 3-day forecast
β β βββ HourlyForecast.jsx # 24-hour forecast
β β βββ WeatherDetails.jsx # Detailed metrics
β βββ services/ # API services
β β βββ WeatherServicesClient.js # Met Office API client
β βββ utilities/ # Helper functions
β β βββ weatherCodes.js # Weather code mappings
β βββ WeatherApp.jsx # Main app component
β βββ main.jsx # App entry point
β βββ style.css # Global styles
βββ docs/ # Documentation
β βββ API.md # API documentation
β βββ DEPLOYMENT.md # Deployment guide
βββ .env.example # Environment template
βββ .gitignore
βββ eslint.config.js # ESLint configuration
βββ index.html # HTML template
βββ package.json # Dependencies and scripts
βββ README.md # This file
βββ tailwind.config.js # Tailwind CSS config
βββ vite.config.js # Vite configuration
The app uses the Met Office DataHub API to fetch weather data. See docs/API.md for detailed API documentation.
- Site-specific forecast: Provides hourly weather data for specific coordinates
- Geolocation: Browser-based location detection
- App requests user's location via geolocation API
- Coordinates, timestep and other options are sent to Met Office API
- Weather data is processed and displayed
- Data refreshes automatically
- Frontend Framework: React 19
- Build Tool: Vite 7
- Styling: Tailwind CSS 4
- Icons: Lucide React
- Date Handling: Day.js
- Linting: ESLint 9
- Components: Use functional components with hooks
- Styling: Use Tailwind CSS classes
- State Management: React useState and useEffect
- Error Handling: Implement try-catch blocks for API calls
- Performance: Use React.memo for expensive components
- Create feature branch:
git checkout -b feature/new-feature - Add components in appropriate directories
- Test thoroughly
- Update documentation
- Submit pull request
See docs/DEPLOYMENT.md for detailed deployment instructions.
- Vercel: Connect GitHub repository for automatic deployments
- Netlify: Drag and drop
distfolder or connect repository - Azure Static Web Apps: Use Azure CLI or GitHub Actions
- Development: Uses Met Office API directly (not recommended for production)
- Production: Should use backend proxy to protect API keys
- Chrome 88+
- Firefox 84+
- Safari 14+
- Edge 88+
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Update documentation
- Submit a pull request
Please use the GitHub issue tracker to report bugs or request features.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
- Met Office for providing the weather data API
- Lucide for the beautiful weather icons
- Tailwind CSS for the utility-first CSS framework
If you encounter any issues:
- Check the troubleshooting guide
- Search existing GitHub issues
- Create a new issue with detailed information
Author: Ricardo Garcia
Version: 1.0
Last Updated: January 2025
