Navigation.decideBack
luastra/navigationNavigation.decideBack(options: any): string
Evaluates the current modal, application stack, browser history, and root-exit conditions and returns the bounded Back action the application should take. It centralizes priority so platform Back behaves consistently.
Before you use it
Add luastra/navigation to this module's dependencies in luastra.json, then import it with require("luastra/navigation"). No host capability is required for in-memory navigation. Browser URL/history synchronization additionally needs luastra/host and navigation.history.
How it fits
The operation updates or creates application-owned navigation state synchronously. Keep stacks and compilers outside app.render, inspect every result.success field, then render from the accepted current entry.
When to use it
Use Navigation.decideBack inside a system_back handler when several layers may consume Back. Execute the returned decision explicitly—close a modal, pop a route, delegate to history, acknowledge handled, or request exit.
Parameters
| Parameter | Type / values | Description |
|---|---|---|
| options | any | Current modal, local-stack, history, and root conditions used to choose one Back decision. |
| options.modalOpen | boolean | Whether Back should dismiss the currently open modal first. |
| options.canBack | boolean | Whether admitted navigation history has an earlier entry. |
Returns
string — the validated canonical string produced by this operation.
What happens next
A validated compiler, stack, decision, or result record; host history changes only when the application requests them separately.
Failures and fixes
Invalid definitions, unknown routes, malformed parameters, excessive history depth, or incompatible snapshots return bounded errors or fail construction. Navigation result records use success:boolean with optional fields, so verify the field you need after checking success.
Availability
Public-source alpha API in 0.5.0-alpha; URL integration is a separate host capability.
Focused example
local Navigation = require("luastra/navigation")
local decision = Navigation.decideBack { modalOpen = helpOpen, canBack = navigation.canBack() }Continue with a complete recipe
This checked recipe uses Navigation.decideBack inside complete authored files with the required manifest, test, and run steps.
Open synchronize Browser and system Back recipe