← Navigation and routes

Navigation.MutationResult

luastra/navigation

Navigation.MutationResult is a result record with a boolean success field and optional success- or failure-specific fields. Check success before reading entry, location, changed, or error; the exported declaration does not encode automatic Luau union narrowing.

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 type describes a route, stack, compiler, or checked result used by navigation operations.

When to use it

Use Navigation.MutationResult for checked navigation operations. Test result.success first, then explicitly verify the optional field needed by that branch; do not assume the boolean field narrows this record as a tagged union.

Fields or definition

ParameterType / valuesDescription
successbooleanDiscriminator that must be checked before reading branch-specific fields.
changedbooleanWhether the requested navigation mutation altered the current stack.
errorRouteError?Bounded failure information, or nil on the successful branch.

Error codes

This is the complete closed vocabulary emitted by the named operation in this Source SDK contract.

CodeWhen it occurs
invalid_entryThe typed route entry cannot be generated.
unknown_routeThe entry names a route absent from the compiler.
invalid_parameterA required path parameter is missing or invalid.
missing_queryA required query parameter is absent.
invalid_queryA supplied query parameter cannot be decoded or validated.
location_too_largeThe generated canonical location exceeds 2048 bytes.
stack_depth_exceededPush would exceed the configured navigation stack depth.

SDK type flow

Produced by

Navigation.createRouter

What happens next

A checked route/navigation annotation.

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.

Exact declaration

export type MutationResult = { success: boolean, changed: boolean, error: RouteError? }

Continue learning

Companions

Navigation.RestoreErrorNavigation.RestoreResultNavigation.decideBack

Complete inventory

View all pages in Navigation and routes
← Previous: Navigation.EntrySnapshotNext: Navigation.EntryStack →