Edge Side Rendering (ESR) with Cloudflare Workers #1899
Replies: 2 comments
-
Hey! Thanks for sharing this idea! Given that it's an idea and not an issue I've converted this to a discussion. Using Cloudflare workers to do SSR instead of needing to run Node on your own server is definitely appealing. I don't understand all the nuances of doing this though, so really don't have a great gut sense of what kind of changes would be required in Inertia to support this. If there's a couple simple changes that could be made to Inertia to support this, that's cool, but I'm not sure we want to require a bunch of Cloudflare specific implementation code in Inertia itself. To me that would be better handled via some type of Cloudflare + Inertia plugin. Also, just being honest, I don't personally have a lot of time to invest in this particular problem right now. We have a number of more pressing improvements we want to make to Inertia core. But if you wanted to put together a PR outlining how to do this (ideally with the minimum number of changes possible), I'd be happy to have a peek at it. Just fair warning: there's a decent chance it doesn't get merged in if it feels at all too complicated, as it would then become code that we're responsible for maintaining. Hope that makes sense! 🤙 |
Beta Was this translation helpful? Give feedback.
-
Consider me interested |
Beta Was this translation helpful? Give feedback.
-
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:
<div id="app" data-page="
data.ReactDOMServer.renderToString
, ideally using a ESR specific JS bundle containing the relevantjsx
data.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:
As opposed to either CSR:
Or traditional SSR:
Beta Was this translation helpful? Give feedback.
All reactions