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 .stew file 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