Building a Weather App Using React and OpenWeather API

Creating a weather app is one of the best beginner-friendly React projects to sharpen your skills while learning how to work with APIs. In this guide, you\’ll learn how to build a simple yet fully functional weather application using ๐—ฅ๐—ฒ๐—ฎ๐—ฐ๐˜ and the ๐—ข๐—ฝ๐—ฒ๐—ป๐—ช๐—ฒ๐—ฎ๐˜๐—ต๐—ฒ๐—ฟ ๐—”๐—ฃ๐—œ in 2025.

๐—ช๐—ต๐˜† ๐—•๐˜‚๐—ถ๐—น๐—ฑ ๐—ฎ ๐—ช๐—ฒ๐—ฎ๐˜๐—ต๐—ฒ๐—ฟ ๐—”๐—ฝ๐—ฝ?

A weather app teaches you several essential development concepts, including:

  • Fetching live data from APIs
  • Managing component state
  • Handling user input
  • Working with async functions
  • Displaying dynamic UI based on API responses

These skills are vital for real-world React applications.

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿญ: ๐—ฆ๐—ฒ๐˜ ๐—จ๐—ฝ ๐—ฌ๐—ผ๐˜‚๐—ฟ ๐—ฅ๐—ฒ๐—ฎ๐—ฐ๐˜ ๐—ฃ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜

Start by creating a new React project:

npx create-react-app weather-app
cd weather-app
npm start

Your project will run at http://localhost:3000.

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฎ: ๐—š๐—ฒ๐˜ ๐—ฎ๐—ป ๐—ข๐—ฝ๐—ฒ๐—ป๐—ช๐—ฒ๐—ฎ๐˜๐—ต๐—ฒ๐—ฟ ๐—”๐—ฃ๐—œ ๐—ž๐—ฒ๐˜†

Visit https://openweathermap.org/api, create an account, and generate a free API key.

Youโ€™ll use the Current Weather Data endpoint:

https://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_KEY}

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฏ: ๐—–๐—ฟ๐—ฒ๐—ฎ๐˜๐—ฒ ๐˜๐—ต๐—ฒ ๐—ฆ๐—ฒ๐—ฎ๐—ฟ๐—ฐ๐—ต ๐—จ๐—œ

Add an input field and button to allow users to search for a city:

<input 
  type=\"text\"
  placeholder=\"Enter city\"
  value={city}
  onChange={(e) => setCity(e.target.value)}
/>
<button onClick={getWeather}>Search</button>

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฐ: ๐—™๐—ฒ๐˜๐—ฐ๐—ต ๐—ช๐—ฒ๐—ฎ๐˜๐—ต๐—ฒ๐—ฟ ๐——๐—ฎ๐˜๐—ฎ

Use fetch() or axios inside an async function:

const getWeather = async () => {
  const response = await fetch(
    `https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${API_KEY}&units=metric`
  );
  const data = await response.json();
  setWeather(data);
};

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฑ: ๐——๐—ถ๐˜€๐—ฝ๐—น๐—ฎ๐˜† ๐˜๐—ต๐—ฒ ๐—ช๐—ฒ๐—ฎ๐˜๐—ต๐—ฒ๐—ฟ ๐—œ๐—ป๐—ณ๐—ผ๐—ฟ๐—บ๐—ฎ๐˜๐—ถ๐—ผ๐—ป

Render temperature, humidity, wind speed, and weather conditions:

<h2>{weather.name}</h2>
<p>Temperature: {weather.main.temp}ยฐC</p>
<p>Humidity: {weather.main.humidity}%</p>
<p>Condition: {weather.weather[0].description}</p>

๐—™๐—ถ๐—ป๐—ฎ๐—น ๐—ง๐—ต๐—ผ๐˜‚๐—ด๐—ต๐˜๐˜€

With just a few lines of code, youโ€™ve built a fully functioning weather app using React and the OpenWeather API. You can enhance it by:

  • Adding icons
  • Showing 5-day forecasts
  • Detecting user location
  • Adding beautiful animations

This project builds a strong foundation for working with APIs and dynamic UIsโ€”skills every modern frontend developer needs.

If you are looking for any services related to Website Development, App Development, Digital Marketing and SEO, just email us at nchouksey@manifestinfotech.com

#ReactJS #React #OpenWeatherAPI #WeatherApp #JavaScript #WebDevelopment #FrontendDevelopment #APIs #Coding #LearnReact #ReactProjects #WeatherAPI #FetchAPI #ModernWebDev #ReactTutorial #DevCommunity #Programming #100DaysOfCode #WebApp #DeveloperLife #ReactTips #React2025 #APIIntegration #OpenWeather #FrontendEngineer #CodeNewbie