@@ -200,17 +200,23 @@ With `ssr: true` — **SSR start mode**:
200200 client — e.g. @cloudflare/vite-plugin — with no hand-written ordering
201201 plugin; setups without another orchestrator keep Vite's stock
202202 build-everything behavior, just client-first.
203- - ** Prod** : the server bundle's entry is ` virtual:solid-ssr-handler ` , whose
204- ` handleRequest(request) ` export maps a web-standard ` Request ` to a
205- streamed ` Response ` — adapter-agnostic, so any node server / worker /
206- runtime mounts SSR in one line:
203+ - ** Prod** : the server bundle's entry is ` virtual:solid-ssr-handler ` .
204+ Its named ` handleRequest(request) ` export maps a web-standard ` Request `
205+ to a streamed ` Response ` ; its default ` { fetch(request) } ` export provides
206+ the same handler in the Fetchable shape used by Workers, Nitro, Netlify
207+ Functions, Bun, and ` deno serve ` :
207208
208209``` js
209- import { handleRequest } from ' ./dist/server/server.js' ;
210+ import app , { handleRequest } from ' ./dist/server/server.js' ;
210211// serve dist/client statically, everything else:
211212const response = await handleRequest (request);
213+ const sameResponse = await app .fetch (request);
212214```
213215
216+ The Fetchable wrapper deliberately accepts only the request. Hosts may pass
217+ environment or execution-context arguments after it; those are not the
218+ Solid options accepted by ` handleRequest ` 's second parameter.
219+
214220- ** Preview** : ` vite build && vite preview ` runs the production artifact
215221 with no server file — Vite's preview statics serve ` dist/client ` , and
216222 everything else (pages, the server-function endpoint, middleware)
@@ -402,31 +408,23 @@ server-function middleware pre-loads the referenced module, then dispatches
402408through the same handler), so one middleware chain and one request event
403409front pages and server functions identically.
404410
405- ** ` external: true ` ** hands the server side of start mode to a host integration
406- that owns the server environment — build wiring and HTTP serving alike. The
407- plugin skips its start-mode server-build config (no ` dist/server ` output or
408- builder flag; the host's orchestrator drives the server build) and stands
409- its dev middlewares down (SSR serving and the server-function endpoint
410- both). Start mode still provides everything the host loads through its own
411- environment: the generated entries, the client manifest, and the
412- ` virtual:solid-ssr-handler ` request handler — which self-serves in dev,
413- inlining the entry graph's CSS through a virtual dev-styles module (HMR
414- included) and composing the server-function endpoint, so
415- ` handleRequest(request) ` is the whole contract in dev exactly as in
416- production.
417-
418- Three switches cover host-owned setups, broadest first:
419-
420- 1 . ** Nothing — capability detection.** When a provider (e.g.
421- @cloudflare/vite-plugin ) replaces the dev server's ` ssr ` environment with
422- its own non-runnable one, the plugin detects that and stands the dev
423- middlewares down automatically; the handler self-serves as above. Zero
424- config.
425- 2 . ** ` start.external: true ` ** — the explicit whole-server switch: everything
426- detection does, plus skipping the server-build wiring. Also needed when
427- the provider owns a _ differently named_ environment (not ` ssr ` ), which
428- detection can't see.
429- 3 . ** [ ` serverFunctions.devMiddleware: false ` ] ( #optionsserverfunctions ) ** —
411+ The normal ` ssr ` environment exposes the default Fetchable handler as its
412+ ` index ` service entry in development and production. Provider Vite plugins
413+ can adopt that environment directly: they supply its runtime and build
414+ orchestration while Solid continues to supply the application entry,
415+ manifest, middleware, and server-function dispatch. When a provider replaces
416+ the development environment with a non-runnable one, Solid detects that
417+ ownership and stands its HTTP middlewares down automatically.
418+
419+ Two explicit switches remain for custom host setups:
420+
421+ 1 . ** ` start.external: true ` ** — hands the whole server side to a host that
422+ does not adopt Solid's normal ` ssr ` environment. Solid skips its
423+ server-build wiring and stands its development middlewares down, while
424+ continuing to provide the generated entries, client manifest, and
425+ ` virtual:solid-ssr-handler ` . This is mainly for differently named or
426+ independently configured environments.
427+ 2 . ** [ ` serverFunctions.devMiddleware: false ` ] ( #optionsserverfunctions ) ** —
430428 the narrow, endpoint-only switch: keeps start mode's server build and SSR
431429 serving, hands only server-function dispatch in dev to the host. For
432430 setups without ` start ` , or when only the endpoint should move.
0 commit comments