← Host capabilities

Host.storageSet

luastra/host
Host.storageSet(name: string, value: string): RequestId

Starts an asynchronous write of a bounded string to the named host storage entry and returns a RequestId. Resolve confirms whether the host committed the value.

Before you use it

Add luastra/host to this module's dependencies in luastra.json, then import it with require("luastra/host"). Declare storage.set 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.storageSet after State.encode or another explicit serialization step. Track the RequestId when UI must report save progress or failure, and never store credentials merely because the API accepts a string.

Parameters

ParameterType / valuesDescription
namestringStable application-owned storage key to write.
valuestringBounded serialized value to persist.

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 requestId = Host.storageSet("game-state", snapshot)

Complete inventory

View all pages in Host capabilities
← Previous: Host.storageGetNext: Host.launchUrl →