"When's the next eclipse visible from here?" sounds like a lookup. It's actually two hard problems stacked on top of each other: predicting when an eclipse happens, and predicting whether it's visible from one specific point on Earth. The total solar eclipse crossing Spain on 12 August 2026 — the first over the Spanish mainland in over a century — is a perfect worked example, so I'll use it throughout.
This is a write-up of how we built the prediction and countdown logic behind a small eclipse tracker. No framework lock-in; the ideas port to any language.
1. Where eclipse predictions actually come from
You do not compute eclipses from scratch in a web app. The orbital mechanics (lunar position to arc-second precision, Besselian elements) are solved problems, and re-deriving them in JavaScript is how you ship a tracker that's quietly wrong.
Instead you consume a canon — a precomputed catalog of eclipses with their circumstances. NASA's Five Millennium Canon of Solar Eclipses is the reference dataset; for each event it gives the instant of greatest eclipse (in Terrestrial Time), the magnitude, and the Besselian elements that let you reconstruct the shadow's geometry.











