web · git:20260908.bd22ac8 · 2026-09-08 · sha256 8ecd036c6b49481b

web git:20260908.bd22ac8A

Immutable. This exact content never changes and is served at /api/v1/blob/8ecd036c6b49481b.

---
description: Web platform runtime — rendering, SSR, Portal, Dynamic
globs: packages/web/**
alwaysApply: false
---

# Solid Web (`@solidjs/web`)

## Package Role

Web-specific runtime providing DOM rendering, hydration, SSR methods, DOM operations, and web-only components. Has conditional exports: browser gets `dist/web.js`, server environments get `dist/server.js`.

## Client Entry (`src/index.ts`)

Re-exports from `client.js`:
- `render`, `hydrate`, `insert`, `spread`, `getNextElement`, `SVGElements`, `clearDelegatedEvents`

Additional exports:
- `Portal`, `Dynamic`, `createDynamic`
- Flow controls re-exported from `solid-js`
- `isServer: false`, `isDev: boolean`

## Server Entry (`server/index.ts`)

Re-exports from `../src/server.js`:
- `renderToString`, `renderToStringAsync`, `renderToStream`
- SSR helpers: `ssr`, `ssrElement`, `ssrClassList`, `ssrStyle`, `ssrAttribute`, `escape`

Additional:
- Simplified `Dynamic` (no memoization — server is stateless)
- `Portal` throws error (not supported server-side)
- `isServer: true`, `isDev: false`
- `provideRequestEvent` uses `AsyncLocalStorage` for request context

## Portal Component

Renders children to a different DOM location (defaults to `document.body`).

- Uses text markers (`treeMarker`, `startMarker`, `endMarker`) for tracking
- Creates element proxy to track `_$host` property
- SVG-aware
- Cleanup removes all nodes between markers

## Dynamic Component

Renders components or elements dynamically based on `component` prop.

- `createMemo` caches the component reference
- Handles: function components, string tags (HTML/SVG via `SVGElements` set), undefined
- Hydration-aware via `sharedConfig.hydrating` and `getNextElement()`
- Uses `spread()` to apply props to native elements

## Submodules (each with its own export path and source directory)

- **`server-functions/`** (`./server-functions`, `/server`, `/client`, `/rich-args`) — the server-function runtime: request-event scoping (`provideEvent`), invocation wrapping, argument/result (de)serialization over seroval, failure sanitization on the result walk, request body caps, and the encrypted flash-cookie mechanism for no-JS form flows (AES-GCM, key derived via HKDF from the bundler-injected `globalThis.__SOLID_SECRET__`, domain-separated). The conformance matrix and pinned rulings live in `test/server/server-function-matrix/MATRIX.md` — consult it before changing semantics; add rulings there when making them.
- **`frames/`** (`./frames`, `/server`, `/client`) — frames transport: eager client consumer + transport with a lazily-loaded codec.
- **`serialization/`** (`./serialization`, `./serialization/decode`) — the seroval-based streaming codec shared by server functions and frames; the decoder owns promise lifecycle (every deferred it creates must be owned/defused — see the #3235/#3267 rulings in the matrix).
- **`storage/`** (`./storage`) — persisted storage helpers over `seroval`/`seroval-plugins`.

## Server-Mock (`src/server-mock.ts`)

Browser-safe stubs that log errors if server APIs are accidentally used in browser: `renderToString`, `renderToStringAsync`, `renderToStream`, SSR helpers.

## Build Outputs

- `dist/web.js` — production browser
- `dist/web.dev.js` — development browser (with `_SOLID_DEV_` enabled)
- `dist/server.js` — production server (Node/Deno/Worker)
- `dist/server.dev.js` — development server (`development` export condition, nested under `node`/`worker`/`deno`)

Every dev artifact is `<entry>.dev.{js,cjs}` beside its prod `<entry>.{js,cjs}` — the same rule for `frames/`, `server-functions/`, and the other packages. Dev-ness is a build mode, not an entry.

Rollup with Babel for JSX transformation, `@rollup/plugin-replace` for dev/prod flags.