Skip to main content

API and recipes

Find public UI entry points. Add route scrolling, reading outlines, and Open Graph images.
3 min read

Use public package paths rather than importing files from dist. The quickstart covers installation; site compositions documents the page components.

Public entry points#

EntryExported surface
@n3wth/ui/siteSite components, N3wthProvider, n3wthTheme, ReadingOutline, useRouteScrollReset
@n3wth/ui/primitivesCore Astryx exports, plus ToastViewport and ToastViewportProps
@n3wth/uiRoot adapters, hooks such as useTheme, tokens, cn, provider, theme, and OGCard
@n3wth/ui/ogOGCard and OGCardProps
@n3wth/ui/visualsVisualBand, AssembleField, ForkLight, ConvergeLight; props types for the first two
@n3wth/ui/site.cssShared generated foundation and visual styles
@n3wth/ui/tailwind-theme.cssTailwind token bridge
@n3wth/ui/stylesCompatibility styles with the shared foundation
@n3wth/ui/themeRetained theme CSS export
@n3wth/ui/tailwindRetained CommonJS Tailwind preset
@n3wth/ui/fonts/*Font paths; only the manifest's selected families ship in npm

JavaScript entries provide ESM imports and type declarations. The CSS theme export is not the JavaScript n3wthTheme object; import that object from site or the root entry.

For a React Router application, mount this component inside your router:

This follows the current docs app. The hook records unmodified same-origin anchor clicks to a different pathname with no hash, then scrolls to the top when that destination becomes active.

It deliberately leaves hash scrolling and browser Back/Forward to the browser or router. It is not a general scroll restoration manager: programmatic navigation without an anchor click and query-only changes do not trigger its reset. Avoid mounting competing scroll-reset implementations.

Add a reading outline#

ReadingOutline delegates its item model and scroll-spy behavior to the native Outline. Its items type is OutlineItem[] from the pinned dependency. Each item supplies an id, label, and heading level.

Render an outline alongside matching section IDs, inside the provider from the quickstart:

PropDefaultBehavior
itemsRequiredNative outline items targeting the article's sections
labelOn this pageOutline label and disclosure button text
collapsiblefalseEnables a disclosure, initially closed
classNameUnsetAdditional wrapper class

The outline uses compact density. Supply matching article targets and verify their navigation in the consuming app.

Generate a Next.js Open Graph image#

In a Next.js App Router project, create app/opengraph-image.tsx:

OGCard accepts one required prop, title: string. It renders the package's mark and title on a dark background using inline styles. It does not accept a description, logo URL, color theme, or image dimensions. The image response supplies dimensions; keep titles short enough for the fixed title styling and inspect the resulting image.

Sources#