Not only React anymoreStepperize now runs in Vue, Svelte, Solid, Angular, Lit, and HTML
Skip to Content
Stepperize

Server rendering

SolidStart and any other Solid SSR setup, with no configuration.

The stepper and the primitives render on the server and hydrate in place.

  • The flow is created when the component runs, so the server renders the right step: the first one, the one in snapshot, or the one in step.
  • Ids come from createUniqueId, so aria-controls and aria-labelledby match between the server and the client.
  • No callback runs on the server. onChange, onFinish, onInvalidStep and the guard only run in the browser.
  • The package contains no JSX: there is nothing for your bundler to compile differently for the server.
  • renderToString, renderToStringAsync and renderToStream all work. A flow inside a Suspense is rendered once its data has loaded, on the right step.

Load the snapshot on the server and pass it in; the first HTML is already on the right step.

src/routes/onboarding.tsx
import { createAsync, query } from "@solidjs/router";
import { Show } from "solid-js";
import { onboarding } from "~/onboarding";

const getSnapshot = query(async () => {
  "use server";
  // `null` means nothing was saved; `undefined` means it has not loaded yet.
  return (await readOnboardingSnapshot()) ?? null;
}, "onboarding");

export default function Onboarding() {
  const saved = createAsync(() => getSnapshot());

  return (
    <Show when={saved() !== undefined}>
      <onboarding.Provider snapshot={saved() ?? undefined} onChange={saveOnboardingSnapshot}>
        <OnboardingSteps />
      </onboarding.Provider>
    </Show>
  );
}

snapshot is read once, when the flow is created. To replace the state later, call stepper.restore(snapshot).

Tabs without triggers

A Stepper.Root assumes it will have triggers and renders its panels as tab panels. When it mounts with none, it switches to groups named by each step's title. If your flow never has triggers and you want the server HTML to say so from the start, pass linear or render your own markup with the headless entry.

Edit on GitHub

Last updated on

On this page