Status pages
Whole pages for the states every site has: not found, failed, offline, down, not allowed.
Overview
A route that cannot show its content: use the status page that names the state.
Pick page
Page not found
The page you are looking for does not exist or has moved.
import { NotFound } from "@hackcove/ui";
<NotFound homeHref="#" />
NotFound: the reader needs a way home, and a retry would load the same nothing.Something went wrong
An error stopped this page from loading. You can try again.
import { ErrorPage } from "@hackcove/ui";
<ErrorPage onRetry={() => {}} homeHref="#" />
ErrorPage with a retry for a missing page promises that trying again helps, and it does not.Error detail
Something went wrong
An error stopped this page from loading. You can try again.
Request 4f2a91 failed: upstream timed outimport { ErrorPage } from "@hackcove/ui";
<ErrorPage detail="Request 4f2a91 failed: upstream timed out" onRetry={() => {}} homeHref="#" />detail is a request id or a short message the reader can quote, and onRetry offers another go.Something went wrong
An error stopped this page from loading. You can try again.
TypeError: Cannot read properties of undefined
at loadBuild (build.ts:42:9)
at async handler (route.ts:17:3)import { ErrorPage } from "@hackcove/ui";
<ErrorPage
detail={
"TypeError: Cannot read properties of undefined\n at loadBuild (build.ts:42:9)\n" +
" at async handler (route.ts:17:3)"
}
onRetry={() => {}}
homeHref="#"
/>Usage
- Pick the page by the state:
NotFoundfor a missing page (404),Forbiddenfor a page the reader may not see (403),ErrorPagefor a failure (500),Offlinefor no connection,Maintenancefor a site that is down on purpose. - The copy is fixed, so every site reads the same. Change the heading with
titleand the text with children only when the state needs a specific line. homeHrefadds a "Back to home" button; with a router,renderHomedraws it with the app's own<Link>.onRetryadds a "Try again" button onErrorPageandOffline;actionreplaces it with the one action that fits, and the home link turns outline beside it. Do not offer a retry where trying again cannot help.- On
ErrorPage,detailis a request id or a short message a reader can quote. Never a stack trace. - Render one as the content of an
AppShell, or on its own in aContainer.
Accessibility
- Each page is a
CenteredLayoutcard, so the title is the page'sh1and the copy under it is a paragraph. detailis shown in aCodeBlocklabelled "Error".- The buttons are a
Buttonand aButtonLink, with their own focus rings; "Back to home" is a real link. - The pages do not set an HTTP status; send the 404, 403 or 500 from the server.
API
NotFound
404: the page is not there.
actionThe primary action; the home link turns outline beside it.
- Type
ReactNode
childrenReplaces the default body copy.
- Type
ReactNode
homeHrefAdds a "Back to home" button linking here. With neither this nor renderHome there is no home link.
- Type
string
renderHomeDraws the home link with the app's own router <Link>, as on ButtonLink.
- Type
LinkRender
titleReplaces the default heading.
- Type
ReactNode
Forbidden
403: signed in, or not, but not allowed here.
actionThe primary action; the home link turns outline beside it.
- Type
ReactNode
childrenReplaces the default body copy.
- Type
ReactNode
homeHrefAdds a "Back to home" button linking here. With neither this nor renderHome there is no home link.
- Type
string
renderHomeDraws the home link with the app's own router <Link>, as on ButtonLink.
- Type
LinkRender
titleReplaces the default heading.
- Type
ReactNode
ErrorPage
500 or any failure. detail is the error text, shown in a CodeBlock under the copy; pass it only where a reader may see it (a request id, a message), never a stack trace. onRetry adds a "Try again" button, unless action replaces it.
actionThe primary action; the home link turns outline beside it.
- Type
ReactNode
childrenReplaces the default body copy.
- Type
ReactNode
detail- Type
string
homeHrefAdds a "Back to home" button linking here. With neither this nor renderHome there is no home link.
- Type
string
onRetry- Type
() => void
renderHomeDraws the home link with the app's own router <Link>, as on ButtonLink.
- Type
LinkRender
titleReplaces the default heading.
- Type
ReactNode
Offline
The device has no connection. onRetry adds a "Try again" button, unless action replaces it.
actionThe primary action; the home link turns outline beside it.
- Type
ReactNode
childrenReplaces the default body copy.
- Type
ReactNode
homeHrefAdds a "Back to home" button linking here. With neither this nor renderHome there is no home link.
- Type
string
onRetry- Type
() => void
renderHomeDraws the home link with the app's own router <Link>, as on ButtonLink.
- Type
LinkRender
titleReplaces the default heading.
- Type
ReactNode
Maintenance
The site is down on purpose and will be back.
actionThe primary action; the home link turns outline beside it.
- Type
ReactNode
childrenReplaces the default body copy.
- Type
ReactNode
homeHrefAdds a "Back to home" button linking here. With neither this nor renderHome there is no home link.
- Type
string
renderHomeDraws the home link with the app's own router <Link>, as on ButtonLink.
- Type
LinkRender
titleReplaces the default heading.
- Type
ReactNode