inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.02k stars 405 forks source link

Edge Side Rendering (ESR) with Cloudflare Workers #1898

Closed iamacarpet closed 2 weeks ago

iamacarpet commented 3 weeks ago

As an idea, we are floating around the option of introducing Edge Side Rendering (ESR) on Cloudflare Workers.

What if we want the benefits of SSR, without needing the NodeJS runtime & the associated CPU usage server side?

Cloudflare Workers provides a JavaScript runtime that proxies requests to an origin, while allowing requests and HTML DOM to be modified before being returned to the client - this means it should be possible to:

The main challenge I foresee at the moment is the need for an ESR specific bundle to be loaded by the worker, so it can proxy any application running InertiaJS and doesn't need to be specifically deployed with the application data - it'll request the JS bundle with the jsx data, as a client would to perform CSR.

I'm not asking for this to be implemented for us - if we go ahead with the idea, I'll be happy to take it towards a proof-of-concept - however, what is the community appetite like for something like this?

Is it something anyone else would find useful? And/or, would you consider accepting it upstream?

As an example architecture:

laravel-inertiajs-esr

As opposed to either CSR:

laravel-inertiajs-csr

Or traditional SSR:

laravel-inertiajs-ssr