Get OpenWeather API key
⏱️ 1 hour
const API_KEY = import.meta.env.VITE_WEATHER_API_KEY
const BASE_URL = "https://api.openweathermap.org/data/2.5"Sign up at openweathermap.org
Free tier allows 60 calls/minute
⚠️ Common Pitfalls:
Call OpenWeather API
⏱️ 3-4 hours
const fetchWeather = async (city: string) => {
const response = await fetch(/weather?q=&appid=&units=metric)
if (!response.ok) throw new Error("City not found")
return response.json()
}Use async/await for API calls
Add loading and error states
⚠️ Common Pitfalls:
Show weather information with icons
⏱️ 3-4 hours
<div className="weather-card">
<h2>{weather.name}</h2>
<img src={http://openweathermap.org/img/wn/@2x.png} />
<p>{weather.main.temp}°C</p>
<p>{weather.weather[0].description}</p>
</div>Use OpenWeather icon URLs
Format temperature with toFixed(1)
⚠️ Common Pitfalls:
Add extended forecast
⏱️ 2-3 hours
const forecast = await fetch(/forecast?q=&appid=&units=metric).then(r => r.json())Use forecast endpoint
Group data by day
⚠️ Common Pitfalls:
Get user location automatically
⏱️ 1-2 hours
navigator.geolocation.getCurrentPosition((position) => {
const { latitude, longitude } = position.coords
fetchWeatherByCoords(latitude, longitude)
})Use navigator.geolocation API
Handle permission denial gracefully
⚠️ Common Pitfalls:
Deploy to Vercel
⏱️ 1 hour
vercel --prodAdd environment variables in Vercel
⚠️ Common Pitfalls: