A Server Component can render every FUNSTACK UI part directly. Which behaviour works before hydration depends on how much of it the platform does.
Hydration is the moment React attaches to server-rendered HTML in the browser: until then the page is plain HTML that the browser alone drives, and afterwards React's event handlers and state are live.
"use client"The package is built unbundled: one output file per source file, and every file that uses a client-only API keeps its "use client" directive. The component namespaces (Tabs, Accordion, ...) are plain objects of client references, so this works in a Server Component:
// app/settings.tsx: a Server Component, no "use client"
import { Tabs } from "@funstack/ui/tabs";
export function Settings() {
return (
<Tabs.Root defaultValue="general">
<Tabs.List aria-label="Settings">
<Tabs.Tab value="general">General</Tabs.Tab>
<Tabs.Tab value="billing">Billing</Tabs.Tab>
</Tabs.List>
<Tabs.Panel value="general"><GeneralSettings /></Tabs.Panel>
<Tabs.Panel value="billing"><BillingSettings /></Tabs.Panel>
</Tabs.Root>
);
}Compound parts find their Root through context, and a Server Component cannot read context, so parts are client modules. The exceptions are Progress and Meter: their Roots have no "use client" (they only compute, then render a context provider created in a client module), so a Server Component renders the Root on the server, may pass it function props, and only the small context module and the parts reach the browser. Separator has no "use client" either and reads no context at all: rendered by a Server Component, it runs on the server, function props included, and sends no code to the browser.
A framework that renders several server payloads into one page must give each its own identifierPrefix, or server-rendered ids from different payloads can collide.
// vite.config.ts
export default defineConfig({
optimizeDeps: { exclude: ["@funstack/ui"] },
plugins: [/* funstackStatic(...) or rsc(...), react() */],
});Without it the dev server loads the library twice. The parts a Server Component renders are loaded unbundled from node_modules, because their "use client" is on each part's file rather than on the subpath entry. A client component's import of the same subpath gets Vite's pre-bundled copy instead. Each copy has its own contexts, so a part from one copy does not see the other's Root or Popup: a NavigationMenu.Link in a client component, inside a Popup that a Server Component rendered, does not close it.
In development the library logs an error when parts of two copies are mounted on one page. It matters if parts of the two copies are nested or share a page; two separately bundled apps on one page (an embedded widget, micro-frontends) log it too, and there they can ignore it.
Import from the subpaths (@funstack/ui/tabs) in client components. FUNSTACK Static pre-bundles the root entry @funstack/ui even when it is excluded, so a client component that imports from the root entry still gets a second copy.
"JS-free" on this site (the JS-free mode of a component, the native Tooltip path in Chromium) means two things: no behaviour JavaScript runs on the native path, because the browser does the interaction, and the server HTML works before hydration and without it. It does not mean "no client bundle". The parts are "use client" modules, so in a Server Components app they are shipped and hydrated with the page like any client component, whatever props they receive.
For scale, measured on FUNSTACK Static (the stack this site is built with): a page whose Server Components render no client component at all still loads about 76 KB gzip of framework runtime (React, react-dom and the RSC client) and hydrates the document. The parts add a few KB on top: between 2 and 5 KB gzip per component in the ones measured, and less each when several share internals. Other RSC hosts were not measured; Next.js App Router and Waku also boot a client runtime on every page.
Where a page really ships no JavaScript, such as server rendering or a static prerender that is never hydrated (react-dom/static prerender, renderToString), "use client" has no effect and the parts' HTML works as is, to the extent described under Before hydrationbelow. There is no separate variant of the parts without "use client": it was considered in issue #19 and not built, since it would save those few KB but not the runtime. For a single form control, the component page has a Plain HTML section where that is an option: the HTML a Server Component can render instead, and what it gives up (for example Switch).
A Server Component can only pass serialisable props, so it cannot pass a plain function as an action. It can pass a Server Function, which works directly because details serialises cleanly (see Action props):
import { Accordion } from "@funstack/ui/accordion";
import { saveOpenSections } from "./actions"; // "use server"
<Accordion.Root defaultValue={user.openSections} valueChangeAction={saveOpenSections}>
...
</Accordion.Root>Passed directly, the Server Function is awaited: the part shows pending state and rolls back on failure, and while the call runs, React holds every other transition in the app (Pending actions hold other transitions). Pass it directly when the UI should wait for the save. For a save in the background, wrap it in a Client Component, (v) => { void serverFn(v); }: a Server Component cannot pass that function. For Next.js, which also runs Server Functions one at a time, see Next.js App Router.
On the server, details has no event and no reject: neither crosses the wire. A Server Function refuses a change by throwing (the nearest Error Boundary); to show your own message and roll back instead, wrap it on the client and call details.reject() there (see With a Server Function). In a production build React does not send a thrown message to the browser, so the boundary cannot show it (Thrown errors are redacted).
A Server Function can be passed to an on* handler too: it is called and not awaited, nothing shows pending, and a rejection goes to reportError.
Example: Dialog
A Dialog closed by its Close button is a request (openChangeAction), and closed with Escape a fact (onOpenChange). To remember either, pass the Server Function to both props. It receives (open, details); this dialog has no Trigger, so it is only ever called with false.
<Dialog.Root
defaultOpen={!user.sawWelcome}
openChangeAction={rememberClosed}
onOpenChange={rememberClosed}
>The server HTML of every part carries its markup, its ARIA attributes and its data attributes, so it is accessible and styled from the first paint. What the user can do before hydration depends on who performs the interaction:
<details> that opens, a native input that toggles and posts with its form, a dialog opened by an invoker command, a tooltip shown on interest (where the engine implements interestfor). Components are built on these elements wherever the platform offers them (see Browser-owned state).details.reason === "platform" (see Action props).formAction, a form's action) submit before hydration through React's progressive enhancement.Each component page says exactly what works before hydration in its Before hydration section.
Example: Accordion
An Accordion without value props runs in JS-free mode: the browser owns every <details open>, so opening and closing, the exclusive group and find-in-page all work before hydration; hydration only adds arrow-key navigation and disabled. With value props (library mode) the native toggle still works before hydration, and items opened then are reconciled on mount with one valueChangeAction call.
This FAQ is rendered by a Server Component in JS-free mode. It opens and closes before the page has hydrated, and in any page that works without JavaScript. (This site streams each page behind a Suspense boundary, which needs a small inline script to reveal it, so here it needs JavaScript enabled, but not the library's.)
A headless React component library built for Async React: transitions by default, action props, Suspense-native content.
No. It renders <details> and <summary>. Try your browser's find-in-page for the word zeppelin: the browser opens the matching item by itself.
Only a zeppelin, to show that closed items stay searchable.
// No "use client": this file is a Server Component. The Accordion has no value props, so it runs
// in JS-free mode: the browser owns <details open>, `exclusive` becomes the native `name` group,
// and opening an item works before hydration (and with JavaScript off).
import { Accordion } from "@funstack/ui/accordion";
const faq = [
{
id: "what",
question: "What is FUNSTACK UI?",
answer:
"A headless React component library built for Async React: transitions by default, action props, Suspense-native content.",
},
{
id: "js",
question: "Does this accordion need JavaScript?",
answer:
"No. It renders <details> and <summary>. Try your browser's find-in-page for the word zeppelin: the browser opens the matching item by itself.",
},
{
id: "zeppelin",
question: "Is anything hidden in here?",
answer: "Only a zeppelin, to show that closed items stay searchable.",
},
];
export function AccordionFaq() {
return (
<Accordion.Root exclusive className="demo-accordion">
{faq.map((item, index) => (
<Accordion.Item
key={item.id}
value={item.id}
defaultOpen={index === 0}
className="demo-accordion-item"
>
<Accordion.Trigger className="demo-accordion-trigger">
<h4>{item.question}</h4>
</Accordion.Trigger>
<Accordion.Panel className="demo-accordion-panel">
<p>{item.answer}</p>
</Accordion.Panel>
</Accordion.Item>
))}
</Accordion.Root>
);
}