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 the official TinyGo toolchain installed through the CLI for compact binaries. Switch to a local TinyGo install if you want to manage the toolchain 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, official TinyGo installed by Gothic
WasmCompiler: routes.GothicTinyGo,
// LocalTinyGo: uses `tinygo` from $PATH
WasmCompiler: routes.LocalTinyGo,
// Golang: standard go, GOOS=js GOARCH=wasm, full stdlib
WasmCompiler: routes.Golang,Use TinyGo when compact WASM downloads are the priority. Smaller client assets improve page loading and Core Web Vitals, supporting both user experience and SEO. Choose Golang when a route needs the full Go standard library or when faster local compilation is more important than output size.
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 official TinyGo toolchain:
# Download and cache official TinyGo
gothic wasm install
# Show the installed TinyGo toolchain
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.
