[]previous and next page

Early events and HydrationScript

A click made before the bundle has hydrated is normally lost.

For agentsUpdated

A click made before the bundle has hydrated is normally lost. generateHydrationScript() (or <HydrationScript /> in server JSX) returns a small inline script for the head of the page. It records click and input events on the document; hydrate() attaches its handlers, then re-dispatches the recorded events on their targets, so the click works.

tsx
import { HydrationScript } from "@shadow-js/web/server";

<head>
  <HydrationScript nonce={nonce} />
</head>;

Pass eventNames to record other events (plain lower-case names). The nonce is written only when it is a plain token. Replayed events are new Event objects (a MouseEvent keeps its coordinates); the page's own event listeners see the replayed events, not the originals. Start's data block is unchanged; the script is for events only.