Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Server rendering

ARC UI components server-render through @lit-labs/ssr intodeclarative shadow DOM: a <template shadowrootmode="open">the browser turns into a real shadow root while parsing, before any JavaScript runs.

All 195 custom elements (components and their child items) render this way. Server rendering is optional. A page with no build step, or one loading ARC UI from a CDN, works without it.

What it fixes

Many ARC UI components take their content from attributes, not slots. Before JavaScript loads, or without it, a tag like this one is empty. There's no heading or description, and nothing for a crawler to read.

Here is the same tag after the server renderer, with Lit's hydration markers left out. The content is in the HTML response:

71 of the 195 elements have no slots at all, so without server rendering their content isn't in the HTML. Components that take their content from slots already have it in the page, and gain less.

Rendering and hydrating

On the server, render as you would any Lit template:

On the client, import the hydration entry before any component:

Without it, when an element upgrades, Lit renders its template from scratch into the shadow root the server already filled. That throws away identical DOM and causes the flash server rendering is meant to prevent. With it, Lit adopts the existing nodes and renders nothing. The order matters because hydration support patchesLitElement's update path, and a component class defined before the patch never gets it.

The FOUC guard

base.css hides ARC UI elements until they upgrade, so a page doesn't flash unstyled custom elements. A server-rendered element hasn't upgraded yet but is alreadyfinished, so that rule would hide its content until hydration. Server rendering would then give you a longer blank screen instead of a shorter one.

Opt the page out at the root:

You have to set it yourself because CSS can't detect a declarative shadow root. The browser consumes the <template> during parsing and leaves nothing a selector can match.

Component coverage

pnpm check ssr renders every element in Node and fails on any that throws. It runs in CI. On the server, Lit runs the constructor, willUpdateand render, and none of connectedCallback,firstUpdated, updated, or a reactive controller'shostConnected. Browser work belongs in those.

All 195 pass, so none of them has to be client-only.

A second test checks that every component's docs preview, server-rendered, looks the same before its script arrives as after. That includes components built from their children: breadcrumbs, navigation menus, tabs, accordions and lists arrive with their items, and nothing moves when the script loads. The two exceptions depend on the current time: arc-clock shows it, and arc-activity-heatmapwithout an end-date ends today. Only the browser knows either.

Client-side routers

A router that fetches the next page and parses it with DOMParser gets declarative shadow roots as inert templates: only the page parser attaches them. Astro's<ClientRouter /> is one. Attach them before the swap:

Without it, every component on the incoming page renders a fresh copy next to an inert template, and nothing hydrates.

Framework support

@arclux/arc-ui/ssr doesn't need a framework's component graph. A framework's server render produces HTML, and every <arc-*> in it can be rendered to a declarative shadow root from the markup alone. So it takes HTML and returns HTML, whatever produced it.

  • Nuxt, SvelteKit, Angular Universal, Next, Astro, or a string you built by hand: pipe the rendered HTML through it. This site's Astro build runs every page through it. The others have no test or example in this repo.
  • React: @lit-labs/ssr-react also works, if you would rather render through the component graph.

It renders any Lit element defined in the process, including other libraries'. Import their registration before rendering (@arclux/brand/register, your own components) and their elements are rendered too.

It needs @lit-labs/ssr, an optional peer dependency. Install it in the project that server-renders. You serve the returned stylesheets from the path they were linked with, and you import @arclux/arc-ui/hydrate on the client before any component is defined. On a bundler that usually means forcing it into its own chunk, since an import statement alone does not control evaluation order.