Skip to content

E0720: A page declared outside pages/ ​

A page is a .vuka.html file under pages/: the file's path is its URL (pages/pets/[id].vuka.html serves /pets/{id}), and vuka writes its registration in pages/route.go. A page is declared nowhere else — not with @web.Live, not with a route decorator on a type, and not by registering its struct from Go with app.Get, app.Live, app.Page or web.Routes.

A route is a page when what it registers is a struct that renders: Live and Page always; otherwise a constructor, func(deps…) *T, whose *T is a ui.Node or whose T embeds ui.Live, or a route with ui.Island(…). A function is a handler — an API — whatever it returns: data, nothing, an error, or a ui.Node it builds from components, such as a fragment a form post answers with. Handlers stay app.Get and the other verbs in Go, or a file of GET/POST/… functions under pages/api/.

Reported by the compiler (a decorator), by vukavet (a registration from Go, outside a generated file or a test, which may mount the page it tests), and at start-up (a decorator on a constructor).

Wrong ​

vuka
// pets.vuka
package app

@web.Live("/pets/{id}")
type Pet struct {
	ui.Live
	ID int
}
go
// main.go
app.Get("/about", NewAbout)
html
<!-- pages/pets/[id].vuka.html -->
<script lang="go">
package pets

type Pet struct {
	ui.Live
	ID int
}
</script>

<h1>Pet {ID}</h1>
html
<!-- pages/about.vuka.html -->
<script lang="go">
package pages

type About struct{}
</script>

<h1>About</h1>

Released under the MIT License. Vuka builds on Go and its tools, which are made by the Go Authors. Vuka is not affiliated with Google or the Go project. Go is a trademark of Google LLC.