Gothic Framework G symbol

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 pkg/wasm (import . "github.com/felipegenef/gothicframework/v2/pkg/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 gothicframework wasm install once to download the managed TinyGo toolchain:

# Download and cache the managed TinyGo 
 gothicframework wasm install 

 # Print the managed TinyGo version 
 gothicframework wasm version 

 # Compile WASM binaries for all ClientSideState pages 
 gothicframework wasm 

 # Remove public/wasm/ and public/wasm_exec.js 
 gothicframework wasm clean 

Note: 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, deploy your Gothic app to AWS!