A weather application built with React, Vite, and Tailwind CSS. Features a clean UI with real-time weather data fetched through Netlify serverless functions.
- Real-time Weather Data: Get current weather information for any city worldwide
- Dynamic Weather Icons: Visual weather representation based on conditions
- Detailed Weather Info: Temperature, feels like, humidity, pressure, and wind speed
- Serverless Backend: Secure API calls through Netlify Functions
- Error Handling: User-friendly error messages and loading states
- Frontend: React 19, Vite
- Styling: Tailwind CSS v4
- Icons: Lucide React
- Backend: Netlify Serverless Functions
- Weather API: OpenWeatherMap
- Deployment: Netlify
- Node.js (v18 or higher)
- npm or yarn
- OpenWeatherMap API key
-
Clone the repository
git clone <your-repo-url> cd netlify-serverless-function
-
Install dependencies
npm install
-
Set up environment variables
Create a
.envfile in the root directory:OPENWEATHER_API_KEY=your_openweathermap_api_key_here
To get an API key:
- Sign up at OpenWeatherMap
- Navigate to your API keys section
- Copy your API key
-
Run the development server
npm run dev
The app will be available at
http://localhost:3000
To test the serverless functions locally:
npm startThis will start the Netlify dev server with function support.
netlify-serverless-function/
├── netlify/
│ ├── functions/
│ └── weather.js # Serverless function for weather API
├── public/
│ └── vite.svg
├── src/
│ ├── App.jsx # Main application component
│ ├── index.css # Global styles
│ └── main.jsx # Application entry point
├── index.html
|── netlify.toml # Netlify configuration
├── package.json
├── vite.config.js
└── eslint.config.js
npm run dev- Start Vite development servernpm run build- Build for productionnpm run start- Start Netlify dev server with functionsnpm run preview- Preview production build
- API keys are stored as environment variables
- Serverless functions handle API calls securely
- CORS headers are properly configured
- Input validation prevents malicious requests
- OpenWeatherMap for weather data
- Lucide React for beautiful icons
- Tailwind CSS for styling
- Netlify for hosting and serverless functions
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Include your Node.js version and operating system