Proof of Concept to serve svelte generated pages on GoLang HTTP server with server data being sent as props to svelte components.
Svelte - Cybernatically enhanced webapps
Vite - Next Generation Frontend Tooling
Fiber - An Express-inspired web framework written in Go.
git clone https://github.com/sachinbhutani/gosvelte gosvelte
cd gosvelte/svelte
npm install
npm build
cd gosvelte/go
go run go/server.go
GoFiber can be used to render static html pages with javascript code As svelte is combined to pure js, JS build with svelte can be served directly on a static go server
With static served svelte pages, any data from backend needs to be requested using 'fetch' which needs an additional round-trip from client to server.
Fiber allows to render HTML templates with data from the backend, this data can be passed on to the svelte components and hydrated on the client side. passing props during html page rendering, saves the additional round-trip to the server for fetching props.
Check out SvelteKit, which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.