--- name: audit-islands version: 1.1.0 description: | Audit pracht hydration: routes that should use `hydration: "islands"` or `"none"`, dead interactivity, non-serializable island props, and mis-tuned `client` strategies. Use for "audit islands", "reduce hydration", "why is this island not interactive", "check partial hydration". allowed-tools: - Bash - Read - Grep - Glob --- # Pracht Audit Islands Report-only audit of hydration modes and islands usage (see ). pracht hydrates the whole page by default (`hydration: "full"`); routes can opt into `"islands"` (only components from the islands directory hydrate) or `"none"` (zero JS). This audit finds routes shipping JS they don't need and islands wired in ways that break at render time or ship dead handlers. ## Step 1: Enumerate routes and hydration modes MCP: if `pracht dev-mcp` is registered, prefer its `inspect_*`, `doctor`, and `verify` tools to the CLI. ```bash pracht inspect routes --json ``` Prerequisite: `pracht inspect` needs a vite config with the pracht plugin wired up. Each route entry carries `render` and `hydration` (`null` = framework default, i.e. full hydration). Also locate the islands directory: default `src/islands/`, configurable via `pracht({ islandsDir })` in the vite config. In pages-router apps (`mode: "pages"`), hydration is the per-file `export const HYDRATION = "islands" | "none"` constant; islands still live in `src/islands/`. ## Step 2: Measure what each route actually ships ```bash pracht build --json ``` Prerequisite: this runs a full production build (`--json` implies `--analyze`). Interpret the totals hydration-aware: - Full-hydration routes: route chunks + shell chunks + shared entry. - `hydration: "islands"` routes: islands bootstrap + island chunks only — no shared client entry. The listed island chunks are an **upper bound** (every island in the app); a page only downloads the islands it renders. - `hydration: "none"` routes report `0b`. ## Step 3: Run the checks ### 3a. Over-hydration (the headline check) For every route with `hydration` `null`/`"full"`: read the route module, its shell, and their imported components. If the page is mostly static — no hooks, no event handlers, or only one or two isolated widgets — flag it: - Zero interactivity → recommend `hydration: "none"` (`warn`; `info` if the route's total gzip JS is already tiny). - A few isolated widgets → recommend `hydration: "islands"` with the widgets moved into the islands directory (`warn`). Cite the Step 2 total as the payload this change removes. Render-mode fit is owned by `/tune-render-mode`; deep chunk analysis is owned by `/audit-bundles`. Point there instead of duplicating their findings. ### 3b. Dead interactivity on islands routes (`error`) On a `hydration: "islands"` route, everything outside the islands directory renders as inert HTML — an `onClick` in a regular component silently does nothing. Grep the route tree of every islands route for event handlers and hooks in components **not** under the islands directory and flag each one. Islands are auto-discovered from that directory only (default and named function-component exports alike; each becomes its own code-split chunk) — there is no wrapper to mark a component elsewhere as an island. ### 3c. Island props and children (`error`) Island props are serialized to JSON in the HTML. At each island call site on an islands route, flag props that are functions, symbols, bigints, class instances (`Date`, `Map`, ...), JSX elements, or circular — rendering throws a descriptive error naming the offending prop path. Children passed into an island are fine: markup renders once on the server as static HTML, and plain text arrives as a string value. Flag: - a render function passed as children (it throws); - children the island expects to re-render or pass props into, and islands among the children that read context the outer island provides (the browser gives them the default) — those belong inside the island or need a prop; - an island that splits markup children with `toChildArray`, `Children.map`, or `Children.count` (tabs, carousels): it receives one opaque node, so labels belong in props and panels are toggled through a ref (`hidden`); - an island that renders `children` inside `

`, ``, or `