You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1e9172a
Browse filesBrowse the repository at this point in the historyBrowse files
feat(platform): support Fetchable server entries with analog({ server })
The custom server entry can now be a Fetchable module (https://fetchable.org)
whose default export has `fetch(request)`, in addition to `createApp()`.
In dev, Analog serves the entry's `fetch` behind Vite through srvx's Node
adapter. The build output keeps the default export, so platforms that invoke
Fetchable modules can run `dist/server/main.js` directly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S3NKyLNGL2d5Df2wt4WNbA
Node servers that have the Node request and response can pass them as a second argument, `handleAnalogRequest(request, { req, res })`, so they become Analog's `REQUEST` and `RESPONSE` tokens. `createAnalogHandler()` does this for you.
147
147
148
+
## Fetchable entry
149
+
150
+
Instead of `createApp()`, the server entry can be a [Fetchable](https://fetchable.org) module: its default export has a `fetch(request)` method that returns a `Response`. Platforms and runtimes that invoke Fetchable modules, such as Netlify Functions, Cloudflare Workers, Deno and Bun, run the built entry without a server of your own.
A Hono app is already Fetchable, so the entry can `export default app`.
169
+
170
+
In development, Analog serves the entry's `fetch` behind Vite. When the entry exports both, `createApp()` is used. The built `dist/server/main.js` keeps the default export and doesn't listen on a port, so the platform serves `dist/client`. Serve it without an index fallback so `/` is server-rendered.
171
+
148
172
## Streaming
149
173
150
174
[Streaming SSR](/docs/features/server/streaming-ssr) works with a custom server: enable `experimental.streaming` and export `renderStream` from `main.server.ts`. Analog returns the document as a stream with `Cache-Control: no-store, no-transform`, and stops rendering when the client disconnects.
@@ -173,7 +197,7 @@ Two details of locale detection apply here as on Nitro:
173
197
174
198
## Building and running
175
199
176
-
`vite build` builds the client into `dist/client` and the server entry into `dist/server/main.js`. Run it with Node:
200
+
`vite build` builds the client into `dist/client` and the server entry into `dist/server/main.js`. Run an entry that starts its own server with Node:
0 commit comments