FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
maxm
maxmcompileAndUploadTinygoWasm
Public
Like
1
compileAndUploadTinygoWasm
Home
Code
2
README.md
main.tsx
Branches
1
Pull requests
Remixes
2
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Sign up now
Code
/
Code
/
Search
README.md

Compile and Upload Tinygo WASM to Val Town Using Deno

Make a Go program like so:

package main import ( "fmt" "net/http" gotown "github.com/maxmcd/go-town" ) func main() { gotown.ListenAndServe(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello World") })) }

Make sure you have tinygo (and optionally wasm-strip) installed. Then run this command with Deno to invoke this script:

deno run --allow-net --allow-run --allow-read \ "https://esm.town/v/maxm/compileAndUploadTinygoWasm?v=58"

That will print out the following:

Running tinygo build -o main.wasm -target=wasi . Compliation complete Running wasm-strip main.wasm Copy the following into a val town HTTP val: import { wasmHandler } from "https://esm.town/v/maxm/tinygoHttp"; const resp = await fetch("https://maxm-wasmBlobHost.web.val.run/jpxqvyy5tphiwehzklmioklpkpz4gpzs.wasm"); const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer())); export default async function(req: Request): Promise<Response> { return handler(req); }

Copy that into a Val and you have a working Go http handler! View that example here: https://www.val.town/v/maxm/crimsonMacaw

Migrated from folder: wasm/compileAndUploadTinygoWasm

Code
README.mdmain.tsx
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.