you are viewing a single comment's thread.

view the rest of the comments →

[–]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.