Eclipse Loader

ProTransitionsWebGLpowered by @vectorvesper/motion

A page loader. While the page loads, a moon slides over a sun. When it is ready the sky goes dark, the corona shows, a bead of light flares at the rim, and the page opens through the moon. One small shader with no 3D library, so the loader is quick to load itself, and it hands its WebGL context back as soon as the page opens.

Eclipse Loader

Included with membership

Members install Eclipse Loader with one command and get the full source, the usage code and the Framer remix, licensed for client work. One membership covers the whole library and the CLI.

When to use it

The first visit to a page that takes a moment to be ready: a WebGL scene, large images, a web font the layout depends on. In the root layout it covers the first load only. Left to itself it follows the page's own loading; pass progress and ready to follow loading of your own.

  • Render it once, high in the tree. It covers the whole screen and removes itself once the page has opened.
  • Pass waitFor for anything else the first view needs, such as a scene's first frame. It is read once, when the loader mounts, so make the promises before then.
  • Let progress only grow. The moon never moves back: a lower value is ignored until a higher one arrives.
  • Keep maxWait short enough that a stuck request never leaves a visitor looking at the loader.

Avoid:

  • Do not put it in a page you navigate to and from. In a page it plays on every visit; in the root layout it plays once.
  • Do not hold the page for what is below the first screen. Lazy images are left out of the wait for that reason.

Props

A page loader. While the page loads, a moon slides over a sun. When the page is ready the sky goes dark, the corona shows round the moon, a bead of light flares at the rim, and the page opens through the moon, all in one second.

<EclipseLoader />

The cover, fixed over the whole screen until the page has opened. It removes itself when it is done.

PropTypeDefaultDescription
progressnumber—How much has loaded, from 0 to 1. Leave it out and the loader follows the page itself: the document, its fonts and images, and `waitFor`. The moon never moves back.
readyboolean—True once the page is ready. Leave it out to finish when the tracked loading has, or when `progress` reaches 1.
waitForreadonly PromiseLike<unknown>[]—More to wait for when `progress` is left out, such as a scene's first frame. Read once, when the loader mounts.
maxWaitnumber10The longest the page is held, in seconds, so a stuck request never traps a visitor.
onDone() => void—Called once the page has opened and the loader is gone.
labelstring"Loading"What a screen reader hears while the page loads.
classNamestring—Class for the cover.
styleReact.CSSProperties—Inline styles on the cover. It is fixed over the whole screen, with a z-index of 1000.

<usePageLoad />

hook

The loader's own tracking, for a progress display of your own: usePageLoad(waitFor?, enabled?). It follows the document, its web fonts, the images in it when it mounts (lazy ones aside) and any promises passed in. A failed request still counts as settled, so the page opens without it.

PropTypeDefaultDescription
progress*number—How much of what it follows has settled, from 0 to 1.
ready*boolean—True once all of it has settled.
Visitors who prefer reduced motion get the eclipse drawn in CSS: the moon steps across as the page loads, and the cover fades once it is ready. Nothing flares or opens.
One small shader on one canvas, with no 3D library, so the loader is quick to load itself. It runs on the shared frame loop, draws only when the picture changes, and hands its WebGL context back the moment the page has opened. Without WebGL it shows the CSS eclipse instead.
If the page becomes ready while its tab is hidden, it opens at once, since nobody is watching. It is announced as a progress bar, with the label as its name.
Client component. The server renders the cover with the eclipse drawn in CSS, so the first paint is already covered, and the shader takes over in the browser. If the script never runs, the cover lifts on its own after 12 seconds, and with scripting off it never shows.
Back to all components