/how-to-build-lovable

How to build Weather application with Lovable?

Step-by-step guide to build modern weather application with Lovable, including API integrations, code examples, responsive design, deployment tips

Book a free  consultation
4.9
Clutch rating 🌟
600+
Happy partners
17+
Countries served
190+
Team members
Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to build Weather application with Lovable?

A minimal, production-ready Weather app in Lovable is best built as a client-side React app that calls a no-key public API (Open‑Meteo) so you can implement and preview entirely inside Lovable (no terminal). I’ll give you step-by-step Lovable chat prompts to create files, wire UI, and optionally add a Supabase favorites feature (that part uses Lovable’s Integrations/Secrets UI). Paste each prompt into Lovable Chat Mode and use Preview → Publish.

 

What we’re building / changing (plain English)

 

Single-page Weather app where a user types a city, the app geocodes the city (open API), fetches current temperature and conditions from Open‑Meteo, and shows a small WeatherCard. Optional: save favorite cities to Supabase.

  • Works inside Lovable Preview without a terminal.
  • Optional Supabase uses Lovable Secrets + Integration to persist favorites.

 

Lovable-native approach

 

Use Chat Mode edits to create files and modify src/App.tsx. Use Preview to run and test. Use Lovable Cloud Secrets UI only if you add Supabase. Publish from the Lovable Publish button. No CLI required. If you want a secure backend proxy for API keys, export to GitHub and deploy externally — I indicate if that’s needed.

 

Meta-prompts to paste into Lovable

 

Prompt 1: Create core UI and fetch logic
Goal: Add a simple UI and weather-fetching module that uses Open‑Meteo (no API key).
Files to create/modify:

  • create src/lib/geocode.ts
  • create src/lib/weather.ts
  • create src/components/WeatherCard.tsx
  • update src/App.tsx (replace default content)
    Acceptance criteria: Done when Preview shows an input, Search button, and a WeatherCard that displays temperature and summary for a searched city.
    Any needed Secrets/integration steps: None for this prompt.
    Prompt content to paste into Lovable Chat Mode:
    ```
    // Create src/lib/geocode.ts
    // Implement a function geocodeCity(city) that calls https://geocoding-api.open-meteo.com/v1/search?name={city}&count=1
    // Return {name, latitude, longitude} or throw on not found.

// Create src/lib/weather.ts
// Implement a function fetchCurrentWeather(lat, lon) that calls https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lon}&current_weather=true
// Return the current_weather object.

// Create src/components/WeatherCard.tsx
// A presentational React component that accepts props: {city, tempC, wind, time} and renders them nicely.

// Update src/App.tsx
// Replace the root UI with:
// - text input to enter city
// - Search button that calls geocodeCity then fetchCurrentWeather and renders WeatherCard
// Include basic loading and error states.


 

Prompt 2: Improve UX and caching
Goal: Add simple localStorage caching for last-searched city and results.
Files to modify:
- update src/App.tsx (add localStorage load/save and show last city on mount)
Acceptance criteria: Done when a search persists across Preview reloads in the Lovable Preview tab.
Any needed Secrets/integration steps: None.
Prompt content to paste:

// Update src/App.tsx
// On mount, read localStorage.lastWeather and prefill UI if present.
// After successful fetch, save lastWeather = JSON.stringify({city, result})
// Ensure loading/error states remain correct.


 

Prompt 3 (optional): Add Supabase favorites (requires Lovable Integrations & Secrets)
Goal: Let signed-in users save favorite cities to Supabase and list them.
Files to create/modify:
- create src/lib/supabaseClient.ts
- update src/App.tsx (add Save Favorite button and list)
Acceptance criteria: Done when Save Favorite writes to Supabase and list displays rows from the favorites table.
Any needed Secrets/integration steps:
- In Lovable Cloud, open Secrets UI and add SUPABASE_URL and SUPABASE_ANON\_KEY.
- Create a Supabase table "favorites" with columns: id (uuid), city (text), lat (numeric), lon (numeric), created\_at (timestamp).
Prompt content to paste:

// Create src/lib/supabaseClient.ts
// Initialize supabase-js using environment variables: SUPABASE_URL, SUPABASE_ANON_KEY (read from process.env or the platform-specific env access).
// Provide helper functions: addFavorite({city, lat, lon}) and listFavorites().

// Update src/App.tsx
// Add "Save Favorite" button that calls addFavorite with current city coords.
// Add a Favorites list UI that calls listFavorites on mount and after save.


 

<h3>How to verify in Lovable Preview</h3>

&nbsp;

<ul>
  <li><b>Type a city name</b> (e.g., "Berlin") and click Search — Preview should show temperature, time, and wind.</li>
  <li><b>Reload Preview</b> to confirm last-search persisted if you added caching.</li>
  <li><b>If Supabase enabled</b>, click Save Favorite and confirm the favorites list updates.</li>
</ul>

&nbsp;

<h3>How to Publish / re-publish</h3>

&nbsp;

<ul>
  <li><b>Use Lovable Publish button</b> to publish changes. Preview reflects edits; Publish makes them live on your Lovable site.</li>
  <li><b>If you added Supabase</b>, ensure Secrets are set in Lovable Cloud before Publish so the live site can access them.</li>
</ul>

&nbsp;

<h3>Common pitfalls in Lovable (and how to avoid them)</h3>

&nbsp;

<ul>
  <li><b>Assuming CLI is available:</b> Don’t expect to run npm installs in Lovable. Use browser-friendly libs and CDNs where possible.</li>
  <li><b>API keys in client code:</b> Avoid embedding secret API keys client-side. Use public no-key APIs like Open‑Meteo or wire up a secure backend outside Lovable (GitHub export + external deploy) if you need secrets not suitable for client exposure.</li>
  <li><b>Secrets visibility:</b> If you use Supabase, set keys via Lovable Secrets UI before Publish; forgetting this causes runtime errors only in Preview/Live, not in Chat Mode edits.</li>
</ul>

&nbsp;

<h3>Validity bar</h3>

&nbsp;

<ul>
  <li><b>Accurate to Lovable’s chat-first workflow:</b> All changes are made via Chat Mode edits, Preview, Secrets UI, and Publish. No terminal steps required.</li>
  <li><b>If you need a secure backend or custom build steps:</b> I’ll label them as "outside Lovable (terminal required)" and recommend GitHub export/sync.</li>
</ul>

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

How to add server-side stale-while-revalidate caching to the Weather app

This prompt helps an AI assistant understand your setup and guide to build the feature

AI AI Prompt

How to add per-client rate limiting to the Weather app with Lovable

This prompt helps an AI assistant understand your setup and guide to build the feature

AI AI Prompt

How to add in-memory request metrics & a protected admin endpoint to the Weather app

This prompt helps an AI assistant understand your setup and guide to build the feature

AI AI Prompt

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation
Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

Best Practices for Building a Weather application with AI Code Generators

Use AI code generators inside Lovable to scaffold the UI and API quickly, but treat the generated output as a starting point: secure API keys with Lovable Secrets, implement a server-side proxy (serverless API route) so keys never go to the browser, add caching and rate-limit handling, validate inputs, review and edit generated diffs in Chat Mode, test in Preview, and export to GitHub for CI/tests when you need terminal-level control.

 

Key Practical Best Practices

 

  • Never embed API keys in client code — put them into Lovable Secrets (Lovable Cloud) and reference via environment variables in server code.
  • Use a server-side proxy (API route) to call OpenWeatherMap (or other weather APIs) so keys stay secret and you can centralize caching, rate-limit handling, and validation.
  • Iterate via Chat Mode and file diffs — let the AI generator create files, then review patches and request targeted edits (don’t accept blindly).
  • Test in Preview before Publish — Preview runs your app in Lovable without exposing secrets; after adding Secrets, retest.
  • Export to GitHub for CI, linting, and local runs — Lovable has no terminal, so push to GitHub to run tests or scripts you can’t run inside Lovable.
  • Plan for rate limits and caching — implement short-term cache (TTL) on API responses and backoff on 429s.

 

Minimal secure example (works anywhere Node serverless is supported)

 

// serverless API route: /api/weather
// This keeps the OpenWeather API key on the server-side
import fetch from 'node-fetch'

// Simple in-memory cache (ephemeral in serverless)
const cache = {}

export default async function handler(req, res) {
  // // Validate input!
  const q = (req.query.q || '').trim()
  if (!q) return res.status(400).json({ error: 'Missing q (city or query)' })

  // // Check cache
  const key = `weather:${q.toLowerCase()}`
  const now = Date.now()
  const cached = cache[key]
  if (cached && now - cached.ts < 60_000) return res.json(cached.data)

  // // Use secret from environment; set it in Lovable Secrets UI as OPENWEATHER_API_KEY
  const apiKey = process.env.OPENWEATHER_API_KEY
  if (!apiKey) return res.status(500).json({ error: 'Server misconfigured' })

  const url = `https://api.openweathermap.org/data/2.5/weather?q=${encodeURIComponent(q)}&appid=${apiKey}&units=metric`
  const resp = await fetch(url)
  if (!resp.ok) {
    // // Propagate helpful errors (and handle rate limits)
    const text = await resp.text()
    return res.status(resp.status).json({ error: text })
  }

  const data = await resp.json()
  cache[key] = { ts: now, data }
  return res.json(data)
}

 

// client-side fetch example
// Call the serverless proxy so the API key is never exposed to the browser
async function getWeather(city) {
  // // Basic input sanitation
  const q = city.trim()
  const res = await fetch(`/api/weather?q=${encodeURIComponent(q)}`)
  if (!res.ok) {
    // // handle errors gracefully in UI
    const err = await res.json()
    throw new Error(err.error || 'Unknown error')
  }
  return res.json()
}

 

Lovable-specific workflow tips

 

  • Generate files with the AI, then review the diff patch — ask for specific edits (security fixes, tests, caching) rather than broad rewrites.
  • Set Secrets in Lovable Cloud (OPENWEATHER_API_KEY, SUPABASE\_URL/KEY, etc.) before testing Preview that depends on them.
  • Use Preview to validate behavior; Preview is your safe sandbox inside Lovable (no terminal).
  • When you need to run npm tests, linters, or database migrations, export/sync to GitHub and run CI or local commands there — Lovable doesn’t provide an in-app terminal.
  • Monitor and iterate: add logging, error reporting, and usage metrics; adjust caching/TTL and add exponential backoff for 429s.


Recognized by the best

Trusted by 600+ businesses globally

From startups to enterprises and everything in between, see for yourself our incredible impact.

RapidDev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with.

They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

Arkady
CPO, Praction
Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost.

He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Donald Muir
Co-Founder, Arc
RapidDev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space.

They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Mat Westergreen-Thorne
Co-CEO, Grantify
RapidDev is an excellent developer for custom-code solutions.

We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Emmanuel Brown
Co-Founder, Church Real Estate Marketplace
Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 

This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Samantha Fekete
Production Manager, Media Production Company
The pSEO strategy executed by RapidDev is clearly driving meaningful results.

Working with RapidDev has delivered measurable, year-over-year growth. Comparing the same period, clicks increased by 129%, impressions grew by 196%, and average position improved by 14.6%. Most importantly, qualified contact form submissions rose 350%, excluding spam.

Appreciation as well to Matt Graham for championing the collaboration!

Michael W. Hammond
Principal Owner, OCD Tech

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We’ll discuss your project and provide a custom quote at no cost.