← Host capabilities

Host.historyReplaceLocation

luastra/host
Host.historyReplaceLocation(location: string, stateToken: string): RequestId

Replaces the current browser-history location and state token without extending the Back stack, then returns the document viewport to its start. The host validates and acknowledges the requested history mutation asynchronously.

Before you use it

Add luastra/host to this module's dependencies in luastra.json, then import it with require("luastra/host"). Declare navigation.history in luastra.json. Save the returned RequestId with its purpose and implement app.resolve.

How it fits

The function starts an asynchronous host request and returns immediately. app.resolve receives its success payload or stable failure code; availability and permission can vary by host.

When to use it

Use Host.historyReplaceLocation for redirects, canonicalization, and restoring the initial route when the obsolete location should not remain reachable through Back.

Parameters

ParameterType / valuesDescription
locationstringCanonical admitted replacement location.
stateTokenstringOpaque encoded application state associated with that location.

Returns

RequestId — an opaque request identifier used to correlate the asynchronous completion in app.resolve.

What happens next

A RequestId now, followed later by one matching app.resolve completion.

Failures and fixes

Undeclared capability, unavailable host support, denied permission, invalid input, deadline, network, or internal failure reaches the bounded failure path. Public completion codes are CANCELLED, DEADLINE, FORBIDDEN, INTERNAL, NETWORK, UNAUTHORIZED, and VALIDATION.

Availability

Public-source alpha capability API in 0.5.0-alpha; verify each claimed host independently.

Focused example

local Host = require("luastra/host")
Host.historyReplaceLocation("#/", router.encode())

Continue learning

Prerequisites

Host.historyReplace

Complete inventory

View all pages in Host capabilities
← Previous: Host.historyPushLocationNext: Host.historyBack →