Write your web frontend entirely in Go

Focus on your business logic
and let Datapages generate the boilerplate.

go install github.com/romshark/datapages@v0.4.4
Getting Started Documentation
Templ Go Datastar NATS Server-Sent Events

Code Generation

Define your pages and handlers in pure Go code and let Datapages generate the server, routing, and middleware automatically.

🚀

Always in Sync

Not just a one-time scaffold. Every time you change your source package, Datapages regenerates routing, wiring, and helpers to stay coherent.

🔒

Built-In Linter

Catches naming violations, missing fields, and invalid handler signatures at generation time. Fix mistakes before they reach runtime.

Live Reload Dev Server

datapages watch rebuilds on file changes, regenerates code, and live-reloads the browser. No manual restarts.

📡

Real-Time SSE & CQRS

Dispatch events and handle them with OnXXX methods. Datapages wires up Server-Sent Events, NATS, and CQRS for you.

🔐

Auth & Security

Token-based sessions, automatic CSRF protection, and secure cookie management. Just declare session Session in your handler and let Datapages handle the rest.

What your code looks like

// PageProfile is /profile/{id}
type PageProfile struct{ App *App }

func (p PageProfile) GET(
    r *http.Request,
    session Session,
    path struct {
        ID string `path:"id"`
    },
) (body templ.Component, err error) {
    user, err := p.App.repo.FindUser(path.ID)
    if err != nil {
        return nil, err
    }
    return profilePage(user, session), nil
}

// POSTFollow is /profile/{id}/follow
func (p PageProfile) POSTFollow(
    r *http.Request,
    session Session,
    path struct {
        ID string `path:"id"`
    },
    dispatch func(EventUserFollowed) error,
) error {
    return dispatch(EventUserFollowed{TargetID: path.ID})
}

What Datapages generates

datapagesgen/app_gen.go

Server & Routing

HTTP mux with typed handlers, middleware chain, session cookie management, CSRF validation, error recovery, SSE stream handlers, and event broker wiring.

datapagesgen/href/href_gen.go

Type-Safe URLs

Functions like href.Profile("user-42") that return correct URL strings with path parameters filled in at compile time.

datapagesgen/action/action_gen.go

Type-Safe Actions

Helpers like action.ProfileFollow("user-42") for Datastar form actions with the right HTTP method and URL.

datapagesgen/app_gen.go

SSE Stream Handlers

Per-page streaming endpoints that subscribe to event subjects, deserialize events, and call your OnXXX handlers over Server-Sent Events.

cmd/server/main.go

Server Entry Point

A ready-to-run main package that wires up your app, session store, message broker, and starts the server.