Routing
lua-spa has a built-in router configured entirely in spa.config.json. No extra code needed.
Basic setup
{
"page_title": "my_app",
"entry_component": "App",
"router": {
"routes": [
{ "path": "/", "component": "Home" },
{ "path": "/about", "component": "About" },
{ "path": "/users/:id", "component": "UserDetail" }
]
}
}
Route parameters
Dynamic segments start with :. The value is passed as a prop to the component:
<template>
<h1>User {{ props.id }}</h1>
</template>
Nested routes
{
"routes": [
{
"path": "/dashboard",
"component": "Dashboard",
"children": [
{ "index": true, "component": "DashboardHome" },
{ "path": "settings", "component": "Settings" }
]
}
]
}
Route resolution flow
Wildcard / fallback
{ "path": "*", "component": "NotFound" }
Guard (meta)
Routes support arbitrary meta and a guard field for future middleware hooks:
{
"path": "/admin",
"component": "Admin",
"guard": "auth",
"meta": { "requiresAuth": true }
}