In-app navigation for one region: a retained page stack with named routes and switchable roots (tabs). From panel:router(). Pages are kept (hidden) when backgrounded, so going back restores their scroll and state.
Declare a route from a builder(page, params) that fills the given page element. Returns a Route handle to navigate to. Raises if the router was removed.
Example
local home = router:route(function(page, params)
page:label({ text = "Home" })
end, {
title = "Home",
on_enter = function(page)
print("entered")
end,
})
router:show(home)
Switch the active root to route (tabs); the previous root and its whole sub-stack are retained. Builds the route on first show. Raises if the router was removed.
Example
local inbox = router:route(function(page)
page:label({ text = "Inbox" })
end)
local sent = router:route(function(page)
page:label({ text = "Sent" })
end)
router:show(inbox)
router:show(sent)
print(router.active == sent) --> true
Go back one page: discard the top and reveal the one below with its retained state. Runs the top's on_leave (may veto). No-op at the root; raises if the router was removed.