gowasm-bindgen#

CI codecov Go Report Card Go Reference GitHub release License: MIT

Type-safe Go in the browser. Generate TypeScript bindings from Go source code.

The Problem#

Go compiles to WebAssembly (a binary format), not JavaScript. Bridging Go and JS requires tedious glue code:

// TypeScript has no idea what this returns or accepts
const result = window.myGoFunction(???, ???);  // any

No type safety. No IDE support. Runtime crashes instead of compile errors.

Learn more about the problem →

The Solution#

Write normal Go functions:

func Greet(name string) string {
    return "Hello, " + name + "!"
}

Get typed TypeScript APIs automatically:

// Full type safety - greet(name: string): Promise<string>
const greeting = await wasm.greet("World");

Features#

Zero Boilerplate

Write normal Go functions. No annotations, decorators, or special syntax needed.

Full Type Inference

Types are inferred from Go function signatures. Structs, slices, maps—all handled.

Worker Mode

Non-blocking async calls via Web Workers. Keep your UI responsive by default.

Sync Mode

Direct synchronous calls when you need them. Simple flag to switch modes.

TinyGo Support

Ship 90KB gzipped binaries. Perfect for performance-critical applications.

Standard Go

Works with regular Go compiler too. 2-3MB gzipped for full stdlib access.

Quick Start#

# Install
go install github.com/13rac1/gowasm-bindgen@latest

# Generate TypeScript client and Go bindings
gowasm-bindgen wasm/main.go --output generated

Get Started Live Demos