Skip to Content
BBRICKSv0.7.4
Getting started

Browser support and SSR

Which browsers the styles assume, and which parts need a browser.

Browsers

The package declares no browserslist. The styles are written for evergreen browsers: current Chrome, Edge, Firefox and Safari. These are the CSS features the component styles rely on, found by searching the source:

  • Custom properties everywhere (the whole token system).
  • Flexbox and grid with gap.
  • Logical properties (inset, margin-inline-start, padding-block and friends) for right-to-left layouts.
  • color-mix(), :has(), dvh units and one container query.
  • aspect-ratio, clamp() and prefers-reduced-motion.

The JavaScript targets ES2020 and uses Intl.NumberFormat, Intl.DateTimeFormat (with ar-EG-u-nu-latn so digits stay Western), matchMedia, AbortController and the Clipboard API (copy buttons say "Couldn't copy" when it is blocked).

Older browsers are not tested. Treat anything that predates :has() support (Safari before 15.4, Chrome before 105, Firefox before 121) as unsupported.

Server-side rendering

Parts of the library read window or document and need a browser; parts do not.

Safe to render on the serverNeeds a browser
Presentational components that take props: the kit's primitives, patterns, tables, charts, and the blocks and PR blocksuseViewportTier(initial?) and useIsMobile: in the browser the first render reads window.innerWidth (so a phone never flashes the sidebar); with no window the hook gives initial, else 'desktop', and the first effect then reads the real width
BricksProvider, MoneyNotesProvider, DataProvider, and AppShell (pass its tier, 'desktop', 'tablet' or 'mobile'; without it the server draws the desktop frame)Modal, Drawer and useModalLock / useFocusTrap in effects (they do nothing on the server, and render nothing while closed)
formatMoney, moneyParts, count, shortDate, daysuseReducedMotion returns false on the server and reads matchMedia after mount
The URL helpers: readParams, writeParams, useHashState and the rest return empty values and do nothing without window
createHttpClient (it reads fetch when a request is made)

useViewportTier no longer reads window while rendering on the server, so renderToString(<AppShell tier="mobile" …>) works (the library's own server test does exactly that). Two things to know:

  • On the server useViewportTier() and useIsMobile() answer 'desktop' (or the initial you pass to useViewportTier). In the browser they read the width on the first render, so a server render and a hydrating phone can disagree for one frame. Pass the same first value on both sides, or draw the width-dependent part after mount.
  • AppShell's tier is the first value and it pins the layout: while the prop is set the shell stays in that tier whatever the window does. It is meant for the server render, tests and embedded previews. To follow the window after hydration, stop passing tier once the page has mounted.

The docs examples are rendered once in jsdom as part of the build, which catches an example that throws, but jsdom is not a server render: it has a window.

Right to left

Layout uses logical properties, so setting dir="rtl" on a wrapper mirrors the component. See Languages and RTL.

On this page