Eclipse Loader
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.
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.
| Prop | Type | Default | Description |
|---|---|---|---|
progress | number | — | 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. |
ready | boolean | — | True once the page is ready. Leave it out to finish when the tracked loading has, or when `progress` reaches 1. |
waitFor | readonly PromiseLike<unknown>[] | — | More to wait for when `progress` is left out, such as a scene's first frame. Read once, when the loader mounts. |
maxWait | number | 10 | The 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. |
label | string | "Loading" | What a screen reader hears while the page loads. |
className | string | — | Class for the cover. |
style | React.CSSProperties | — | Inline styles on the cover. It is fixed over the whole screen, with a z-index of 1000. |
<usePageLoad />
hookThe 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.
| Prop | Type | Default | Description |
|---|---|---|---|
progress* | number | — | How much of what it follows has settled, from 0 to 1. |
ready* | boolean | — | True once all of it has settled. |