stew/* Packages / 14.3

🧭 stew/nav

The stew/nav package provides tools to manage programmatic navigation and access client-side URL state in your Wasm bundles.

URL Access

nav.URL string
Returns the current URL at the time of the call (elastic, follows changes).
nav.Query url.Values
Full access to search parameters via Go's standard net/url type.

🚀 Navigation Logic

Stew offers several navigation modes to suit your performance needs.

nav.To(url string) Recommended

Enables Hot Morphing. Stew attempts a partial update via HTMX and Idiomorph for an instant transition without losing Wasm state. If HTMX is not available, it automatically falls back to StandardTo.

nav.StandardTo(url string)

Forces a full page and Wasm bundle reload (standard browser behavior).

nav.Replace(url string)

Replaces the current history entry with the new URL without creating a new step in the browser history.

⏪ History & Control

nav.Back() history.back()
nav.Forward() history.forward()
nav.Reload() location.reload()

Usage Example

<goscript client>
    import "stew/nav"

    onLogout := func() {
        // Replaces the current URL with login without being able to go back
        nav.Replace("/login")
    }

    onSuccess := func() {
        // Smooth navigation to the dashboard
        nav.To("/dashboard")
    }

    onRefresh := func() {
        nav.Reload()
    }
</goscript>