At any moment each context shows either the applet's screen for its page or the website itself. The UI decides which. It renders the screen and its loading, stale and error states, and it shows a context's website with genesis.website.show(contextId) and covers it again with genesis.website.hide(). This guide covers what the user sees while pages load and change.
The router helper, createRouter from @nirvanacp/sdk/router (or mount(element, { router }) in React), makes the decision for you with the default table below. It reads the routes in src/routes.ts, opens a watch of each route's ready read and of the account, and calls website.show and website.hide as the table says. Use it unless the product needs other rules.
- Pass
decide(context, route)in the router options to replace the table. It returns"custom"for the applet screen or"website", and the router still makes the calls. - Without the router, call
website.showandwebsite.hideyourself, and listen withgenesis.website.on("viewWebsite" | "showContext" | "done", fn)for the user's choices in the shell. Without a listener, the client shows the website for View website and for a link opened from outside, and hides it on Done.
Whoever decides, keep the rules below: the user is never left on a blank or stuck screen, and the website shows only when the table says so or the user asks.
The router's default table:
| Context state | What shows |
|---|---|
| A ready page on a route | The applet screen |
| A route page that is loading, within 15 seconds | The applet screen, with its skeleton or the last copy |
| A route page still loading after 15 seconds | The website |
A route page in error while the last copy of that entry is still shown, within the deadline |
The applet screen, with an inline error |
Any other error |
The website |
A route with requiresAccount while the account watch reads signed out (auth) |
The website, at the router's account.signInUrl when it returns one |
A route with onError: "applet" that is loading past the deadline or in error |
The applet screen, with its own error state |
A route with website: true, a URL with no route, or another origin |
The website |
| The user chose View website | The website, until Done |
A route's page is ready when its ready read is truthy; a route without ready is ready once the page is bound. The website appears under a website bar with Done, below the floating menu button. A window the website opens for another site appears as a sheet over the revealed website, only from a tap. A hidden context opens one only with a window grant from the user's tap on the applet UI; it appears as a sheet over the applet, under the website bar, and closing it returns to the applet (see website features). Overlay screens always render over the active context, whatever it shows. Screens never decide this themselves: useRouter().presentation(contextId) reports it, and useRouter().revealed names the context whose website is shown.
How a screen is opened decides what the user sees while the next page loads:
navigate({ url })with the defaultpushmode shows the destination route's screen at once, as a pending entry with statusloading, its own screen id and params, and the next history key. The screen renders its skeleton until the page arrives. The pending entry ends when the page binds, on any other navigation, or afterlimits.documentReadyMs.- A click on the website's own link (
context.click(..., { navigates: true })) andreplacemode start no pending entry. The previous screen stays until the new page binds, which reads as a dead tap and can show the website in between when the previous entry was the website.
Open details, profiles and other destinations with navigate({ url }) from the URL the reader returned. Click the site's link only when the URL is unknown, or when the click does something the URL alone does not.
While a page loads and nothing is cached, the screen renders a skeleton shaped like its destination: rows for a feed, a title and metadata block for a detail, a banner and avatar for a profile. Keep known headings, tabs and the Cancel or Close control available. See design for the look.
const page = useRouter().status();
const stories = useWatch<never, Story>("feed:stories", { reader: "stories" }, { when: FEED_PAGES });
if (stories.order.length === 0) {
if (page.status === "ready" && stories.status === "ready") return <Empty />;
if (page.status === "error" || stories.status === "error") return <LoadError error={page.error ?? stories.error} />;
return <FeedSkeleton />;
}Each watch is in one of five data states, which watchStatus(value) and useWatchStatus return:
| State | Meaning | The screen shows |
|---|---|---|
loading |
No data yet, the page is reading | The skeleton |
fresh |
Data the page just read | The content |
stale |
Data kept from an earlier visit or entry, while the page reads again | The content, with the refreshing state of stale pages |
empty |
The page read and has nothing, or the watch is idle on this URL | The empty state |
failed |
No data and an error | The error with Retry and the website |
Genesis keeps each watch's last value across pages and, with persist, across starts, so most screens open stale and never show a skeleton.
status() is the route's status for the active context, or for the context you name: loading, ready, error, auth or unsupported, with stale, error, params and signedIn. Between a context's document going away and the next one binding, it is loading. Treat empty as a ready page with an empty list, never as "no records yet".
Unknown is not empty either. While the page is loading, a field the reader has not found is missing because the page has not drawn it yet. Show the skeleton for it, and render a fallback such as "(no subject)" or a zero count only once the page is ready and not stale and the field is still missing:
const known = read.messages.length > 0 || (page.status === "ready" && !page.stale);
return known ? <Thread read={read} /> : <ThreadSkeleton />;Each watch keeps the last ready copy of each history entry (up to 16 per context). When the user goes Back, or a page reloads, the screen shows that copy at once with stale: true, on the watch's value and on status(), while the page loads again, and updates in place when the new page is ready.
- Render stale content normally with an unobtrusive refreshing state:
aria-busyon the scroll container and a thin progress bar under the header that appears after a short delay (see motion). Do not replace it with a skeleton. - Disable controls that act on the page while it is stale; the records may no longer match what the site shows.
- When the reload fails, keep the stale content and show a short inline error ("Couldn't refresh. Showing the last copy."). After the deadline the website takes over, unless the route sets
onError: "applet".
A route in error carries status().error with a code and message, and a watch in error carries its own error. Show the message, a Retry that calls reload(), and a View website control that calls viewWebsite(), both from useRouter, so the user can see what the site shows. A watch's error affects only what that watch reads: keep the rest of the screen and say which part could not be read.
When a context starts showing the website, the shell reveals that context's page under the website bar; when it returns to the applet, the shell covers it again. No screen code runs for the switch. Design for it:
- A signed-out user who opens a page that needs an account sees the site's sign-in. Done or Back leaves it and returns past the page that needed the account. When nothing is behind it, because the first context's start page needs the account, Done leaves the applet. After signing in, the applet screen returns on its own.
- A link to a page the applet does not customize opens the website in the same session, with the same history. Back goes to the previous entry, which shows the applet screen again if it has a route.
- A link shared from another app shows the applet screen when it matches a route, like any other navigation, and the website otherwise (see navigation).
- A page that never becomes ready shows the website after 15 seconds. Fix the route's
readyread rather than hiding this. - While the website or a window it opened covers the applet, Genesis does not draw the applet's page. While the page is quiet its document is hidden (
document.visibilityStateishidden), so animations andrequestAnimationFramepause and timers run at most about once a second; scripts and messages keep running. Genesis runs the page in full for about two seconds whenever a message reaches it, and at least every 30 seconds: the document then reportsvisiblebut still draws nothing, sorequestAnimationFramecallbacks wait. Do not readvisibilityStateto learn whether the applet is covered;useRouter().revealedsays that. A script animation (element.animate) that starts or is still running when the page is hidden never ends by itself, so end it withfinish(), as theStagein the UI kit does. The page draws again when the applet's screen returns.
Genesis does not animate the switch between the applet and the website, and the router swaps the screen at once when the page changes. The UI gives its own changes direction and feedback, following motion:
- Animate screen changes from where the screens sit: forward pushes, Back pops, tab roots fade through, sheets rise. Animate a copy of the outgoing screen, so the new screen is live from its first frame and Back never waits for motion. A stale copy shown on Back appears at once, inside the same pop.
- Fade skeletons in after a short delay and let them shimmer; fade content in once where it replaces a skeleton. Cached content shows without a fade.
- Animate state changes on a control the user touched, such as a vote arrow or a saved icon, within about 200 ms.
- Respect
prefers-reduced-motion: drop non-essential motion entirely, and keep every state change and progress indicator.