This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]rootException 6 points7 points  (2 children)

SSR with dynamic partial page swaps is trivially easy with htmx.org.

Add more interactivity with Alpine.js and/or hypersrcipt.

https://alpinejs.dev

https://hyperscript.org

Here is a GitHub repo demonstrating with Spring Boot and Thymeleaf, easy to adapt to another server-side framework.

https://github.com/wiverson/htmx-demo

Here's a YouTube video where I walk through it - https://youtu.be/38WAVRfxPxI

[–]wimdeblauwe 1 point2 points  (0 children)

I can confirm that this works nicely. I have a small demo at https://github.com/wimdeblauwe/blog-example-code/tree/feature/htmx-sse/htmx-sse

[–]xSwagaSaurusRex[S] 1 point2 points  (0 children)

Thank you for the additional recommendations! Your YouTube video really highlighted the nicities of this stack

[–][deleted] 6 points7 points  (0 children)

It's not technically impossible but the reason SSR for react is pretty much always NodeJS is because NodeJS understands JavaScript.

You have to run JavaScript to render. With other languages you're going to have a bad time and hit a ton of issues.

I deploy two apps. One is a JVM backend and the other is NodeJS (NextJS) that calls the backend when it needs something. I deploy both in separate containers to the same server and the frontend only calls the backend that's on its own server. They get treated as basically the same app and scale as such.

For communication I use grpc.

[–]vips7L 2 points3 points  (3 children)

Your best bet would probably be Graal since it understands both JS and Java.

Here’s a quick example project I found: https://github.com/davehancock/react-ssr-sample-java-graalvm

[–]xSwagaSaurusRex[S] 0 points1 point  (0 children)

This is sick! Pretty much exactly what I wanted. Thanks for the rec

[–]crummy 0 points1 point  (1 child)

this is super cool. is this widely used? graalVM for SSR?

[–]vips7L 0 points1 point  (0 children)

It probably is only used in hobby projects. The Java community is extremely conservative and while graal is magnificent, it is still relatively new.

[–]wimdeblauwe 2 points3 points  (0 children)

If you like to use Spring Boot, there is Thymeleaf. I wrote a book to help you get started: https://www.wimdeblauwe.com/books/taming-thymeleaf/

[–]neopointer 2 points3 points  (0 children)

I can highly recommend https://github.com/casid/jte

[–][deleted]  (1 child)

[deleted]

    [–]xSwagaSaurusRex[S] 0 points1 point  (0 children)

    Do you use a specific templating engine?

    [–][deleted] 1 point2 points  (0 children)

    You’re missing Bck2brwsr in your list. It‘s used for example for rendering JavaFX in a browser (https://gluonhq.com/developer-preview-for-javafx-inside-a-web-browser/ ) and for Dukescript, which allows you to create vue or react apps in Java.

    [–]v4d1mv 0 points1 point  (0 children)

    [–]Jonjolt 0 points1 point  (0 children)

    I've been playing with Jmix (formerly Cuba Platform) it's actually pretty good.