Guide / Introduction

✨ Language Summary

Stew is a modern full-stack Go framework for building ultra-fast web applications. Here is a summary of its architecture, syntax, and internal mechanics.

πŸ—οΈ Architecture

  • SSR: Initial rendering on the server for optimal SEO.
  • Wasm: Ultra-lightweight client hydration via TinyGo.
  • SPA Morphing: Smooth navigation without reloads (HTMX + Idiomorph).

πŸ“ Routing

  • File-based: No router configuration; the structure of pages/ defines URLs.
  • Dynamic: Support for [id] parameters.

Templates {{ Go }}

.stew files are HTML templates augmented with Go logic.

{{ if user.IsLoggedIn }}
    <h1>Hello {{ user.Name }} !</h1>
{{ else }}
    <p>Please sign in.</p>
{{ end }}

<ul>
    {{ each products as p }}
        <li>{{ p.Title }} ({{ p.Price }} €)</li>
    {{ end }}
</ul>

πŸ–₯️ Server

Bloc <goscript>

Logic executed during HTML generation. Perfect for DB queries, authentication, and data preparation.

🌐 Client

Bloc <goscript client>

Compiled to WebAssembly. Handles interactivity, DOM events, and reactivity via Signals.

🚦 Fine-Grained Reactivity (Signals)

Stew leverages auto-tracking. Simply call .Get() within an Effect, and it will automatically re-run whenever the Signal is updated via .Set().

<goscript client>
    import "stew/state"
    count := state.New(0) // Creation
    
    state.Effect(func() {
        fmt.Println("Counter:", count.Get()) // Observation
    })
    
    increment := func() {
        count.Set(count.Get() + 1) // Mutation
    }
</goscript>