r/golang - Comment by u/matt-mueller on ”Bud: The Full-stack Web Framework for Go Developers”

Hey u/painya, the Svelte files will get rendered server-side into HTML, then hydrated on the client-side.This is similar to what most other JS frameworks do, it works like this:

  1. Create two builds: one for server, one for browser. Both are built using ESBuild. In development, builds happen lazily upon request, similar to how a CDN like would build JS to be imported. This will hopefully allow the build system to scale for larger apps. Vite was my inspiration here, but it's all done in Go.

  2. V8 and the Svelte compiler are baked into the bud binary. When a request comes in, V8 evaluates the compiler running the server-built page and returns HTML. That's a mouthful, hopefully that makes sense.This was hard to do, but I couldn't live with the tradeoff of choosing between: a modern frontend language vs. performance, SEO and the website working without JS.

I should have shown it in the demo, but if you go through the HN demo, try running `curl :3000` and you'll be overwhelmed with a beautiful HTML soup!