Skip to content

Beta — battle-tested in production

structpagesStruct-based routing for Go web apps

Built on http.ServeMux. gsx and HTMX first. Type-safe URLs.

Quick look ​

gsx
type index struct {
	product `route:"/product Product"`
	team    `route:"/team Team"`
}
type product struct{}
type team struct{}

component (p index) Page() {
	<html>
		<body>
			<h1>Welcome</h1>
			<a href={product{} |> url}>Product</a>
			<a href={team{} |> url}>Team</a>
		</body>
	</html>
}

component (p product) Page() {
	<h1>Product</h1>
}

component (p team) Page() {
	<h1>Team</h1>
}
go
func main() {
	mux := http.NewServeMux()
	if _, err := structpages.Mount(mux, index{}, "/", "Home"); err != nil {
		log.Fatal(err)
	}
	log.Fatal(http.ListenAndServe(":8080", mux))
}

See the full walkthrough →

Resources ​