Yugen UI

StatusPage & ErrorBoundary

StatusPage is a page for HTTP errors (404, 500, 503…), being offline and new versions; ErrorBoundary shows it when its children fail.

status picks the built-in title, description and code (from messages.statusPage): 400, 401, 403, 404, 408, 410, 429, 500, 502, 503, 504, "offline", "update". The code is shown large so it is recognised at a glance, with a readable "Error 404" line; the title is an h1 (or headingAs="h2" inside a region). It never navigates on its own: pass your router's buttons / links to primaryAction and secondaryAction; use children for suggestions or a search box. errorId shows a selectable error ID with a copy button; autoFocus moves focus to the title after a client-side navigation. ErrorBoundary catches render errors in its children: a file that fails to load after a deploy (a tab opened earlier) shows "A new version is available" + Reload, any other error shows 500 + Try again; resetKeys (the path, say) clears the error on navigation. The docs use this component for their own 404 page.

Error 404

Page not found

The link may be mistyped, or the page has moved.

Home

Import

Install from npm, copy the source into your project with @yugen-ui/cli or the shadcn CLI, or import directly when working in this repo.

TSX
// npm install yugen-uiimport { StatusPage, ErrorBoundary, isChunkLoadError, statusPageCopy, type StatusPageStatus } from "yugen-ui";

Variants

Each tile is a standalone example: hover to copy, or press Code to see the source.

Error 500

Something went wrong on our side

It's not you. Try again in a few minutes; if it keeps failing, send us the error ID.

Error ID:7f3a-91c2

Statuses

Built-in copy per status; 500 with a copyable error ID.

Revenue is up 12% this quarter.

ErrorBoundary

Press to make the child fail while rendering: the default 500 page takes its place, and Try again renders the child again.

Usage

Do
  • Say what happened and what to do next; always offer at least one way out (Try again, Home, Search).
  • Wrap the route content in an ErrorBoundary with the path in resetKeys, so an error on one page doesn't blank the whole app.
  • Send errors to your error tracker in onError and show the same ID through errorId.
Don't
  • Don't show stack traces or technical messages to people.
  • Don't use the number alone as the content; always have a written title.
  • Don't reload the page automatically without saying so first.

Props

Prop · TypeDefaultDescription
status400 | 401 | 403 | 404 | 408 | 410 | 429 | 500 | 502 | 503 | 504 | "offline" | "update"Default: —Picks the built-in title, description and code.
codeReactNode | nullDefault: code of statusCode shown large; null hides it.
title / descriptionReactNodeDefault: from statusOverrides the built-in copy; description={null} hides it.
primaryAction / secondaryActionReactNodeDefault: —Action buttons / links (Button, your router's Link).
illustrationReactNodeDefault: —Illustration in place of the built-in code / icon.
errorIdstringDefault: —Error ID to send to support: selectable text + copy button.
headingAs"h1" | "h2"Default: "h1"Element of the title.
autoFocusbooleanDefault: falseMoves focus to the title when shown (client-side navigation).
fullscreenbooleanDefault: falseAt least as tall as the screen.
childrenReactNodeDefault: —Extra content under the description: page suggestions, a search box.
refRef<HTMLDivElement>Default: —Points to the outer element.
ErrorBoundary.fallbackReactNode | ({ error, reset }) => ReactNodeDefault: —Replaces the default page (new version + Reload, or 500 + Try again).
ErrorBoundary.onError(error, info) => voidDefault: —Called when an error is caught.
ErrorBoundary.resetKeysunknown[]Default: —When a value changes, the error clears and the children render again.
ErrorBoundary.statusPagePropsStatusPagePropsDefault: —Passed to the default page (for example fullscreen when wrapping the whole app).
isChunkLoadError(error)(error: unknown) => booleanDefault: —A JS file failed to load after a deploy; reloading the page is enough.
statusPageCopy(status, messages?)(status, messages?) => { title, description }Default: —Built-in copy of a status, for a <title> for example.

Messages

Text built into the component: labels, aria-labels, screen reader announcements.

English by default. Change it with the messages prop of YugenProvider, by the namespace below; messagesVi has the Vietnamese set. See Interface language.

messages.statusPage

Key · TypeDefault (English)messagesVi
eyebrow(code: number) => string

Dòng nhỏ trên tiêu đề, đọc được mã trạng thái.

Default (English)(code) => `Error ${code}`messagesVi(code) => `Lỗi ${code}`
badRequestTitlestring

Tiêu đề và mô tả mặc định theo status.

Default (English)"Bad request"messagesVi"Yêu cầu không hợp lệ"
badRequestDescriptionstringDefault (English)"The link or the data sent isn't in the expected form. Go back and try again."messagesVi"Đường dẫn hoặc dữ liệu gửi lên không đúng dạng. Quay lại trang trước rồi thử lần nữa."
unauthorizedTitlestringDefault (English)"Sign in to continue"messagesVi"Cần đăng nhập"
unauthorizedDescriptionstringDefault (English)"This page is for signed-in accounts."messagesVi"Trang này chỉ dành cho tài khoản đã đăng nhập."
forbiddenTitlestringDefault (English)"No access"messagesVi"Không có quyền truy cập"
forbiddenDescriptionstringDefault (English)"The account you're using can't view this page. Ask an admin for access or switch accounts."messagesVi"Tài khoản bạn đang dùng không xem được trang này. Xin quyền từ quản trị viên hoặc đổi sang tài khoản khác."
notFoundTitlestringDefault (English)"Page not found"messagesVi"Không tìm thấy trang"
notFoundDescriptionstringDefault (English)"The link may be mistyped, or the page has moved."messagesVi"Đường dẫn có thể bị gõ sai, hoặc trang đã đổi chỗ."
goneTitlestringDefault (English)"This page was removed"messagesVi"Trang này đã bị gỡ"
goneDescriptionstringDefault (English)"This content is no longer available."messagesVi"Nội dung này không còn nữa."
tooManyRequestsTitlestringDefault (English)"Slow down a little"messagesVi"Bạn thao tác hơi nhanh"
tooManyRequestsDescriptionstringDefault (English)"Wait a moment, then try again."messagesVi"Đợi một chút rồi thử lại."
serverErrorTitlestringDefault (English)"Something went wrong on our side"messagesVi"Máy chủ gặp lỗi"
serverErrorDescriptionstringDefault (English)"It's not you. Try again in a few minutes; if it keeps failing, send us the error ID."messagesVi"Lỗi không do bạn. Thử lại sau ít phút; nếu vẫn lỗi, gửi mã lỗi cho chúng tôi."
unavailableTitlestringDefault (English)"Down for maintenance"messagesVi"Đang bảo trì"
unavailableDescriptionstringDefault (English)"We're upgrading or under heavy load. Check back in a few minutes."messagesVi"Hệ thống đang được nâng cấp hoặc tạm quá tải. Quay lại sau ít phút."
timeoutTitlestringDefault (English)"The server took too long"messagesVi"Máy chủ phản hồi quá lâu"
timeoutDescriptionstringDefault (English)"The request timed out. The network may be slow, or the server is busy."messagesVi"Yêu cầu đã hết thời gian chờ. Mạng có thể đang chậm, hoặc máy chủ đang bận."
offlineTitlestringDefault (English)"You're offline"messagesVi"Không có kết nối mạng"
offlineDescriptionstringDefault (English)"Check your Wi-Fi or mobile data, then try again."messagesVi"Kiểm tra Wi-Fi hoặc dữ liệu di động rồi thử lại."
updateTitlestringDefault (English)"A new version is available"messagesVi"Đã có phiên bản mới"
updateDescriptionstringDefault (English)"This site was just updated, so the part you have open is no longer on the server. Reload to get the new version."messagesVi"Trang vừa được cập nhật nên phần bạn đang mở không còn trên máy chủ. Tải lại để dùng bản mới."
errorIdstring

Nhãn trước mã lỗi (errorId).

Default (English)"Error ID"messagesVi"Mã lỗi"
copyErrorIdstring

Nút chép mã lỗi và thông báo sau khi chép.

Default (English)"Copy error ID"messagesVi"Sao chép mã lỗi"
copiedstringDefault (English)"Copied"messagesVi"Đã sao chép"
retrystring

Nút của ErrorBoundary: thử render lại / tải lại trang (lỗi nạp file sau khi deploy).

Default (English)"Try again"messagesVi"Thử lại"
reloadstringDefault (English)"Reload"messagesVi"Tải lại"