[Feature]: Server Side Rendering Support For Languages, SSR Everywhere #2009
Replies: 1 comment
-
This requires changes all over the map. It starts with generating the right compiled output for other languages. I've thought about this path somewhat, but our templating is so much more than templating. JS interpolation happens all over the place. It isn't necessarily impossible. Solid's client and server compilation are different, so picturing a different server compilation isn't completely impossible. But a lot of Solid isn't compiler analyzable so we actually have a different server runtime (one without reactivity). Like the I don't think this issue belongs in SolidStart, but I'm not sure where it belongs. This feels like a discussion topic for Solid in general. I'm going to try to move it there. But it might take a few hops. |
Beta Was this translation helpful? Give feedback.
-
@ryansolid
Usually people have servers written in different languages, Other than javascript / typescript. To serve my website on different servers in different languages, I could create a static build and copy the public folder and serve that directory under a route.
This works, However not for server side rendering. Because everything is loaded on client side.
This got me thinking, and usage of template engines in golang, gave me a great Idea. What if we can server side render our app everywhere.
Template engines work by replacing values inside the template. What we need to do is generate a file for every route in that language. That declares a function taking an instance of the object and making references and replacing the values in the string
for example, Our source is following
For the following source, generated template file in golang would look like this
This is a basic example, Users can use useLocation and Javascript expressions over a property present inside "model"
For useLocation the variables could be added to the model, The model could be renamed from "Course" to "InjectionModel", Containing inside it all the properties of request required
For javascript expressions, they could be generated as is, most languages differ slightly in syntax, Which could be improved later on
Ofcourse generating templates for multiple languages like this, requires a lot of effort, I say only a singe language implementation is required and other implementations could be written by users who are willing to contribute.
This is a lot of work and I don't want you to say no because of that.
If there was a single implementation of a JavaScript template, I would write other languages that I require myself. Because generating code is not that hard, The hard part is interacting with API's I don't understand. So a single implementation can serve as a reference and that's all that's needed. A single bare bones not that good implementation of template generation.
Motivation 🔦
I have a GoLang server, I need to install NodeJS on a different container, I also need to make requests server side to my other container which causes some overhead.
If this feature would be implemented, I can write servers in any language I desire. I can server side render everywhere I want. All this without overhead of making http calls or RPC calls.
Beta Was this translation helpful? Give feedback.
All reactions