3 ms·
You can use it for doing server side rendering of React or other JS framework components. I have a VERY rough repository[0] where I tested this out a while back
by jbister 6y ago
You can use it for doing server side rendering of React or other JS framework components. I have a VERY rough repository[0] where I tested this out a while back. The way I did it was to export functions on the global object in JS[1] which could then easily be called from Java code[2]. I'm sure there's a better way to accomplish the same thing.
What I found interesting with this approach is that it allows you to do server side rendering without needing a separate server and without needing any third party dependencies aside from GraalVM itself.
0. https://github.com/JackBister/javalin-preact-archetype https://github.com/JackBister/javalin-preact-archetype
1. https://github.com/JackBister/javalin-preact-archetype/blob/master/src/main/resources/archetype-resources/src/main/resources/frontend/src/server.ts https://github.com/JackBister/javalin-preact-archetype/blob/...
2. https://github.com/JackBister/javalin-preact-archetype/blob/master/src/main/resources/archetype-resources/src/main/java/BundledServerSideRenderer.java#L23 https://github.com/JackBister/javalin-preact-archetype/blob/...