← Host capabilities

Host.launchUrl

luastra/host
Host.launchUrl(): RequestId

Requests the URL or fragment with which the host launched the application and returns a RequestId. The host answers through app.resolve; this function reads launch context and never opens an external destination.

Before you use it

Add luastra/host to this module's dependencies in luastra.json, then import it with require("luastra/host"). Declare app.launchurl.get 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.launchUrl during startup when a deep link or host-provided launch location must select initial application state. Save the RequestId, validate the resolve payload before routing, and use UI.Link—not Host.launchUrl—to open a visible external HTTPS link.

Parameters

No parameters.

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")
local launchRequestId = Host.launchUrl()

local function resolve(id: number, success: boolean, payload: string)
    if id == launchRequestId and success then applyLaunchLocation(payload) end
end

Complete inventory

View all pages in Host capabilities
← Previous: Host.storageSetNext: Host.clipboardWrite →