Compiler Options
Every ClientSideState page compiles to a WASM binary. Gothic gives you three compilers to choose from and two compression formats, all configured per route on the page's RouteConfig.
Important: You must dot-import core/wasm (import . "github.com/gothicframework/core/wasm") for use these helpers, otherwise you will get a tinygo compile error.
By default Gothic uses its own managed TinyGo for the smallest possible binaries. Switch to a local TinyGo install if you want to control the version yourself, or fall back to standard Go WASM when you need the full standard library.
Set WasmCompiler and WasmCompression on the route's RouteConfig:
var MyPageConfig = routes.RouteConfig[MyProps]{
ClientSideState: func() { /* ... */ },
WasmCompiler: routes.Golang,
WasmCompression: routes.BROTLI,
}Here are the three WasmCompiler options side by side. GothicTinyGo is the default and produces the smallest output. LocalTinyGo uses the tinygo binary already on your $PATH. Golang uses the standard Go toolchain with the full standard library available:
// GothicTinyGo: default, managed TinyGo, smallest binaries
WasmCompiler: routes.GothicTinyGo,
// LocalTinyGo: uses `tinygo` from $PATH
WasmCompiler: routes.LocalTinyGo,
// Golang: standard go, GOOS=js GOARCH=wasm, full stdlib
WasmCompiler: routes.Golang,For compression, choose GZIP to emit .wasm.gz files or BROTLI for smaller .wasm.br files. Gothic serves the right variant based on the browser's Accept-Encoding header.
The CLI ships a few commands for managing the WASM toolchain. Run gothic wasm install once to download the managed TinyGo toolchain:
# Download and cache the managed TinyGo
gothic wasm install
# Print the managed TinyGo version
gothic wasm version
# Compile WASM binaries for all ClientSideState pages
gothic wasm
# Remove public/wasm/ and public/wasm_exec.js
gothic wasm cleanNote: you can mix GothicTinyGo and Golang components on the same page. Pick the compiler that fits each route, not the whole app.
Ready to ship? Next, meet the deployment tool that ships your Gothic app to the cloud.
