feat: streaming hydration support for JSX/SSR in Cloudflare Workers environment
Background / Motivation
When building SSR applications with Hono's JSX renderer on Cloudflare Workers, the current implementation returns a fully rendered HTML string. While this works well for simple pages, it misses the opportunity to leverage HTTP streaming for progressive hydration — a technique that significantly improves perceived load time (Time to First Byte / Largest Contentful Paint).
Modern frameworks like React 18+, Solid Start, and Qwik have demonstrated that streaming SSR with selective hydration can cut LCP by 30–60% on cold starts, which is especially impactful in edge environments where CPU time is limited.
Current Behavior
// Current: blocks until full render is complete
app.get('/', (c) => {
return c.html(<MyPage />)
})
// → sends entire HTML document as one chunkThere is no built-in way to flush partial HTML to the client while remaining components are still rendering.
Proposed Solution
Add a streamHtml() / renderToReadableStream() helper that returns a ReadableStream and works natively with the Workers runtime:
import { streamHtml } from 'hono/jsx-stream'
app.get('/', (c) => {
const stream = renderToReadableStream(
<Suspense fallback={<LoadingShell />}>
<AsyncDataPage />
</Suspense>
)
return new Response(stream, {
headers: { 'Content-Type': 'text/html; charset=utf-8' },
})
})Key requirements:
- Compatible with
workerd/ Cloudflare Workers runtime (no Node.js streams) - Honors
<Suspense>boundaries — flushes synchronous subtrees immediately, defers async ones - Works alongside the existing
@hono/react-rendererand native JSX renderer - Optional: inject inline
<script>hydration chunks after async boundaries resolve
Environment
- Runtime: Cloudflare Workers (
workerd) - Hono version: v4.x (latest)
- Renderer:
hono/jsx(built-in) and/or@hono/react-renderer
Alternatives Considered
- Using
hono/streamingwith manual chunked writes — works but requires hand-rolling the HTML structure, no Suspense support - Wrapping in a Service Worker on the client — adds complexity, defeats the edge-first purpose
Additional Context
This would position Hono as a strong SSR framework for edge-first applications on Workers. Happy to prototype an initial implementation if the team is open to the direction.
Source: honojs/hono