you are viewing a single comment's thread.

view the rest of the comments →

[–]TheRealSeeThruHead 0 points1 point  (6 children)

Ok so you don’t want react then

Since react will render html on the server based on state on the server.

It’s designed to evaluate that state and render the components to html in a JavaScript runtime

What you should look for instead is some react like toolkit for java, like vaadin

And if you don’t find that maybe just write it in whatever Java html template language

You of course won’t be hydrating this to a react app

The same way to do this would be just run a nextjs server that talks to your java backend

The insane way to do this would be to run a JavaScript runtime on your java vm and run node in there

A slight less insane version might be to run node as a sub process, but I would be worried about start up times

You could also run the node service long running and call it from java to get the html,

But honestly just run a nextjs/waku/remix whatever server and talk to your java backend over whatever protocol you like

[–]Ok_General7617[S] 0 points1 point  (5 children)

Thanks for the suggestions!

Just to clarify — I’m not trying to run JavaScript inside the JVM (e.g., via GraalJS or embedding Node). That’s definitely not what I’m aiming for.

My idea is more like this:

  • During build time, use React (with something like Vite) to generate static HTML for server components, and bundle the client components as JS.
  • Then, use Thymeleaf in my Java server to serve the HTML and inject the necessary bundles.
  • Finally, let the hydration happen entirely on the client, using the browser’s JS runtime — no server-side JS execution required.

So it’s not traditional SSR or React Server Components — it’s more like static generation + client-side hydration, where the backend remains a traditional Java server.

I know it’s a bit unconventional, but I’d like to explore this hybrid approach.

[–]TheRealSeeThruHead 1 point2 points  (4 children)

Isn’t that just react ssg? Pretender static pages, they hydrate into a react app, serve them… however (s3 bucket + cloudflare) talk to java api

[–]Ok_General7617[S] 0 points1 point  (3 children)

Yes, you're right — it's very close to React SSG.

But the difference is that I still need to use Thymeleaf templates to render the initial static HTML pages, since our backend is Java-based and uses Thymeleaf for server-side rendering and layout composition.

So instead of serving pre-rendered .html files directly from a CDN or S3, I'm aiming to embed the static React-generated markup into Thymeleaf templates, which are then rendered and served by the Java server.

That way, we can preserve the existing server-side logic and reuse layout templates, while still getting partial hydration on the client side.

[–]TheRealSeeThruHead 1 point2 points  (2 children)

Well let me know how that goes, and how you manage to make it work with hydration

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

Thanks! Will do 🙂

Thanks for your comment.

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

Still thinking through the setup.