Deploying Full-Stack RSC to Cloudflare Workers
Zero cold starts, global distribution, and streaming responses.
Deploying React applications to the edge has traditionally been limited to simple static assets or basic SSR. With modern RSC runtimes, we can now stream full-stack applications directly from edge nodes.
Edge Benefits
- Near-Zero Latency: Requests are processed at the data center closest to the client.
- Streaming HTML: Time to First Byte (TTFB) drops dramatically as the shell streams immediately.
- KV and D1 Integration: Co-located storage eliminates round-trip penalties to distant databases.
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const stream = await renderAppToReadableStream(request, env)
return new Response(stream, {
headers: { 'Content-Type': 'text/html; charset=utf-8' },
})
},
}