Gothic Framework G symbol

Sharing Code & Isomorphic Rendering

A local Go package compiled into a per-route WASM helper

Your ClientSideState is no longer limited to same-package helpers and the standard library. In v3 it can import any local package from your project — a shared utils package, a codec, even a templ component you also render on the server. Change the package once and every page that imports it rebuilds.

A single helper package, consumable from any WASM page:

// pkg/wasmutil/format.go
package wasmutil

import "strconv"

func FormatCents(cents int) string {
	return "$" + strconv.Itoa(cents/100) + "." + strconv.Itoa(cents%100)
}

Import it straight into a page's ClientSideState:

import . "github.com/gothicframework/core/wasm"
import "myapp/pkg/wasmutil"

ClientSideState: func() {
	total := CreateObservable(4200)

	Observe(func() {
		SetText("total", wasmutil.FormatCents(total.Get()))
	}, total)
}

Under the hood, the WASM build links your module so any local import path resolves, following the steps shown in the diagram above.

Because the same templ component can render on the server and inside WASM, you get true isomorphic rendering with zero string duplication.

Important: TinyGo doesn't support every stdlib package (for example net/http or crypto/tls). If a local package pulls one in, TinyGo fails with a clear error pointing at the unsupported symbol — switch that route to WasmCompiler: routes.Golang to get the full standard library.

Speaking of compilers — let's pick the right one for each route!