1
🎓 View Certificate (1)
← Back

Build a Weather App

Create a weather dashboard with real-time data from OpenWeather API.

Sign in to track your progress

Step 1: API Setup

Get OpenWeather API key

⏱️ 1 hour

🎬 Video Walkthrough

📝 Code

typescript
const API_KEY = import.meta.env.VITE_WEATHER_API_KEY
const BASE_URL = "https://api.openweathermap.org/data/2.5"
💡 Hints (2 available)
Hint 1 (unlocks after 5min)

Sign up at openweathermap.org

Hint 2 (unlocks after 10min)

Free tier allows 60 calls/minute

⚠️ Common Pitfalls:

  • Store API key in .env file
  • Add .env to .gitignore

Step 2: Fetch Weather Data

Call OpenWeather API

⏱️ 3-4 hours

🎬 Video Walkthrough

📝 Code

typescript
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()
}
💡 Hints (2 available)
Hint 1 (unlocks after 5min)

Use async/await for API calls

Hint 2 (unlocks after 10min)

Add loading and error states

⚠️ Common Pitfalls:

  • Handle network errors
  • Validate city input
  • Show user-friendly error messages

Step 3: Display Weather

Show weather information with icons

⏱️ 3-4 hours

🎬 Video Walkthrough

📝 Code

tsx
<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>
💡 Hints (2 available)
Hint 1 (unlocks after 5min)

Use OpenWeather icon URLs

Hint 2 (unlocks after 10min)

Format temperature with toFixed(1)

⚠️ Common Pitfalls:

  • Convert Kelvin to Celsius if needed
  • Format temperature with 1 decimal
  • Capitalize description

Step 4: 5-Day Forecast

Add extended forecast

⏱️ 2-3 hours

🎬 Video Walkthrough

📝 Code

typescript
const forecast = await fetch(/forecast?q=&appid=&units=metric).then(r => r.json())
💡 Hints (2 available)
Hint 1 (unlocks after 5min)

Use forecast endpoint

Hint 2 (unlocks after 10min)

Group data by day

⚠️ Common Pitfalls:

  • Group forecast by day
  • Show min/max temperatures
  • Handle timezone differences

Step 5: Geolocation

Get user location automatically

⏱️ 1-2 hours

🎬 Video Walkthrough

📝 Code

typescript
navigator.geolocation.getCurrentPosition((position) => {
  const { latitude, longitude } = position.coords
  fetchWeatherByCoords(latitude, longitude)
})
💡 Hints (2 available)
Hint 1 (unlocks after 5min)

Use navigator.geolocation API

Hint 2 (unlocks after 10min)

Handle permission denial gracefully

⚠️ Common Pitfalls:

  • Handle permission denial
  • Provide fallback city
  • Show loading during geolocation

Step 6: Deploy

Deploy to Vercel

⏱️ 1 hour

🎬 Video Walkthrough

📝 Code

bash
vercel --prod
💡 Hints (1 available)
Hint 1 (unlocks after 5min)

Add environment variables in Vercel

⚠️ Common Pitfalls:

  • Add API key to Vercel env vars
  • Test in production mode

Study Timer

🎯 Focus
25:00
Stay focused!
Total Study Time
0m
💡 Work: 25 min • Break: 5 min

⚙️ Technologies

ReactTypeScriptAPI