Guide / 00
Introduction to Stew
Stew is an opinionated Go meta-framework designed for building full-stack web applications served from a single Go binary. It natively integrates Server-Side Rendering (SSR), typed components, file-based routing, hot morphing, and a hybrid isomorphic WebAssembly architecture.
Philosophy
Stew was originally built on top of templ and Go templates. The 0.1 release introduces the native Stew template language (.stew), a custom compiler that transforms these files into idiomatic Go code. The core principles are:
- One file, two contexts. A
.stewfile can contain both server-side logic (native Go) and client-side logic (compiled to Wasm). - Convention over configuration. The directory structure defines the routing β no manual configuration required.
- Go is the language. No obscure DSL: the logic is standard Go inside
<goscript>blocks. - Zero front-end build. No Node.js, no bundler. TinyGo alone for WebAssembly.
Tech Stack
π₯οΈ Server
Go 1.22+ (native)
π Client
TinyGo β WebAssembly
π Partial Updates
HTMX + idiomorph
π₯ Dev Mode
SSE + Air (live reload)
π¨ Styling
Tailwind CSS (CDN)
π CLI
stew (Cobra)
Minimal Project Structure
my-app/
βββ pages/
β βββ @layout.stew β Root layout (HTML shell)
β βββ @page.stew β Route /
β βββ users/
β βββ @layout.stew β Nested layout (optional)
β βββ @page.stew β Route /users
β βββ __id__/
β βββ @page.stew β Route /users/{id} (URL parameters)
βββ component/
β βββ Card.stew β Reusable component
βββ static/
β βββ wasm/ β Automatically generated Wasm binaries
βββ .stew/ β Cache tracker (gitignore)
βββ .stew.yaml β Stew configuration
βββ main.go β Server entry point
βββ stew_router_gen.go β Automatically generated router