Skip to content
jquaggaPublic

About

Simple Weather queries the US National Weather Service or OpenMeteo APIs to provide a responsive weather forecast.

Topics

Resources

Code of conduct

Security policy

Stars

3 stars

Watchers

1 watching

Forks

Latest commit

 

History

666 Commits

Folders and files

Repository files navigation

Simple Weather icon Simple Weather

Simple Weather is a progressive web app which queries the US National Weather Service API — or, worldwide, the Open-Meteo API — to provide a responsive weather forecast.

✨ Demo

Caution

This should not be your only source of weather data and especially not the only source of severe weather alerts! The Open-Meteo (Global) workflow has no alerts or radar at all — only the NWS workflow shows active alerts.

Features

  • Two forecast sources, switchable in the top nav bar (choice persists):
    • NWS — US National Weather Service: current conditions hero with temperature, heat index / wind chill (when NWS provides them), wind, humidity, and precipitation chance; active alerts with app-badge count; radar and watch/warning map overlays
    • OpenMeteo — worldwide Open-Meteo: current conditions hero (temperature + feels-like), next ~24 hours chart (temperature / feels-like / precipitation chance), and a 7-day forecast narrated in NWS Zone Forecast Product style — generated on-device by the bundled src/lib/zfp/ library

Important

The narrative generated from the ZFP library for the OpenMeteo data is a beta and the data source does not include weather alerts. It is a start at applying the US NWS forecast narrative guidelines to the raw data provided from OpenMeteo however it is generated programatically in browser and has some limitations. For example, a hurricane isn't reportable via the OpenMeteo data so ZFP reports "Rain with wind gusts up to 79 mph".

  • Use your current location (Geolocation API) or search for a city: both the NWS and OpenMeteo sides use the Open-Meteo geocoder (pick from up to 5 matches; GPS coordinates on the OpenMeteo side are reverse-labeled via OpenStreetMap Nominatim)
  • Forecast in English, Spanish, or French (switchable in the top nav bar; OpenMeteo narratives are translated too — NWS forecast content stays English, only the header chrome translates there) with metric / US-customary units toggle (defaults follow your browser locale)
  • 7-day forecast cards and NOAA NWS radar (OpenFreeMap basemap, dark-mode aware)
  • PWA with offline fallback: last forecast per location is cached in localStorage, service worker serves /offline when unreachable

Getting started

Prerequisites

  • Node.js 20+ and pnpm — this is a pnpm-only repo (preinstall: only-allow pnpm, engine-strict=true)

Install and run locally

pnpm install
pnpm dev

Useful commands

pnpm check     # typecheck (svelte-kit sync && svelte-check)
pnpm format    # format all files with Prettier
pnpm format:check  # verify formatting
pnpm lint      # eslint (Svelte + TS, Prettier-compatible)
pnpm test      # unit tests once (Vitest, `src/**/*.test.ts`)
pnpm test:watch  # unit tests in watch mode
pnpm test:coverage  # unit tests with V8 coverage (`/coverage`, gitignored)
pnpm build     # production build
pnpm preview   # build + wrangler dev
pnpm deploy    # build + wrangler deploy (Cloudflare Workers)
pnpm cf-typegen  # regenerate src/worker-configuration.d.ts

Note

CI verifies pnpm format:check, pnpm lint, pnpm test, pnpm check, and the pnpm build production build.

Usage

The top nav bar switches providers (NWS / OpenMeteo), UI language (English / Español / Français), and units (°C / °F, OpenMeteo pages only). Choices persist in localStorage. First-time visitors with a non-en-US browser language land on the OpenMeteo workflow; en-US lands on NWS.

NWS home page — pick one of the two options:

  1. Use my location — asks for location permission and navigates to /Weather?lat=&lon= (coordinates are rounded to 4 decimals). Shows a hint if geolocation is blocked in the browser.
  2. Search by city — a city or town name is enough, e.g. Washington, DC. Queries the Open-Meteo geocoder directly from the browser and offers up to 5 matches to pick from (NWS only covers US locations, so pick a US match).

OpenMeteo (/global) home page — same two-card layout:

  1. Use my location — worldwide; GPS coordinates are reverse-labeled into a place name via the same-origin /reverse proxy (OpenStreetMap Nominatim), falling back to raw coordinates.
  2. Search for a city — a city name is enough, e.g. Berlin, Germany. Queries the Open-Meteo geocoder directly from the browser and offers up to 5 matches to pick from.

Geolocation coordinates go directly from your browser to NWS or Open-Meteo (to fetch the forecast); city searches go directly to the Open-Meteo geocoder, and GPS coordinates on the OpenMeteo side pass through this app's /reverse proxy before being forwarded to Nominatim. Coordinates and place names you look up are shared with those providers to fetch data — but never otherwise stored or shared by us.

On /Weather:

  • The header shows City, State, coordinates, and when the forecast was updated (or an Offline — showing cached forecast notice)
  • ← New search returns home; ↻ Refresh re-fetches the current coordinates
  • Radar toggles control the NWS radar and watches/warnings overlays; tiles refresh about every 5 minutes

On /global/weather:

  • Same header/refresh/offline behavior, plus a 7-day forecast narrated in NWS Zone Forecast Product style ("Thursday Night", "Friday Day", …) in your UI language
  • No alerts, radar, or map — Open-Meteo provides none of those through this app

How it works

  • Fully client-rendered SvelteKit app (ssr = false, prerender = true) deployed to Cloudflare Workers via @sveltejs/adapter-cloudflare.
  • /Weather fetches api.weather.gov directly from the browser: points/{lat},{lon} → forecast (7-day text) + forecastGridData (raw gridpoint numbers for the hourly chart: temperature, heat index, wind chill, precipitation chance, humidity, wind — converted from metric to US units, in parallel; alerts resolve independently so a slow alerts endpoint never blocks the forecast).
  • /global/weather fetches api.open-meteo.com via the openmeteo SDK (best_match models, timezone=auto): hourly temperature, humidity, apparent temperature, precipitation/rain/showers/snowfall, cloud cover, wind + gusts, visibility. The framework-free src/lib/zfp/ library slices the hourly data into 6am–6pm day / 6pm–6am night periods starting from the current period, then narrates each one ZFP-style (sky, PoP + qualifiers, temp categories + trends, 8-point wind + gusts, snow accumulations) in metric, converting to US units at display only when the locale calls for it; Spanish/French phrasing is seeded from the NWS AWIPS Translator.py tables (see NOTICE).
  • UI strings are compiled with Paraglide (no localized URLs; sources in messages/*.json, Weblate-friendly) for English, Spanish, and French.
  • src/routes/reverse/+server.ts is a thin proxy to OpenStreetMap Nominatim reverse-geocoding (lat/lon required, 10s timeout) for GPS place names.
  • Chart.js is tree-shaken (chart.js core only, no chart.js/auto, dates via Intl.DateTimeFormat + category scale); MapLibre GL JS is lazy-loaded behind an IntersectionObserver with its worker via ?worker&url + setWorkerUrl.
  • Last forecast per 4-decimal tile is cached in localStorage (1h TTL, max 10 tiles, separate swa:openmeteo: namespace for the Global workflow) for the offline fallback; the service worker is network-first for navigations (falls back to prerendered /offline) and never caches /reverse or ? URLs so forecasts stay fresh.
  • Content-Security-Policy is generated by SvelteKit (csp.mode: hash in vite.config.ts) — do not add one to root _headers.
  • Styling is Tailwind CSS v4 (via @tailwindcss/vite): utility classes in markup plus a small @layer base / @layer components block in src/lib/main.css (typography, buttons, cards, inputs, chips, tables). Dark mode follows prefers-color-scheme; no style="" attributes so the CSP needs no unsafe-inline.

Acknowledgments \ Tech Stack

About

Simple Weather queries the US National Weather Service or OpenMeteo APIs to provide a responsive weather forecast.

Topics

Resources

Code of conduct

Security policy

Stars

3 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages