I’m working on a Golang backend and trying to figure out the best frontend approach. I’ve been using Next.js before but I keep running into issues where I end up using Next API routes instead of my actual Go backend, which makes everything messy.
The main problem is that with client-side rendering, users see a blank page for a few seconds while data loads from my Go API. Even with loading spinners, the user experience feels slow. I want something that can render content on the server like PHP does, but still give me the interactive features of modern JavaScript frameworks.
I’ve heard people recommend Vite with React and a JSON API, but that still has the same loading delay problem. Is there a way to get server-side rendering with my Go backend while keeping JavaScript reactivity for things like button clicks and dynamic updates? I’m looking for a hybrid solution that combines the best of both worlds.
check out templ + htmx. htmx handles all the dynamic interacshuns without needing js frameworks, and templ gives you modern go templates. much easier than wrestling with next.js routing.
Had the same issue with my Go API + React setup. What worked for me: ditch full client-side rendering and use Go’s html/template for server-side rendering instead. Then add Alpine.js or vanilla JS only where you actually need interactivity. Here’s the flow: Go handlers render the initial page, then your dynamic bits talk to your API endpoints. No more blank pages since content loads instantly from the server, but you still get modern interactions where they matter. The trick is figuring out what actually needs JavaScript reactivity vs what can stay as plain server-rendered HTML. This hybrid approach gives you fast initial loads without losing the interactive stuff.
What about Astro with Go? I’ve been playing with this combo recently - Astro does partial hydration so only interactive parts load JS while the rest stays server-rendered. How are you handling auth between your Go API and frontend though? That could change which approach works best.