Skip to content

Search documentation

Enter at least two characters.

    NativeHandle

    SDK 0.1.0-preview.1 · ExperimentalDownload & release notes ↗

    An opaque owned native resource. Close it when it is no longer needed.

    Advanced app/host integration API. Useful for lower-level work; ordinary app authors can start with the app-building path. This is public API, not permission to access private toolkit objects.

    Low-level public host protocol. In preview.2, add Storage.ApplicationId as shown below. Preview.1 needs a custom embedding host that installs the storage provider; its standard SDK cannot provision this scope.

    Where to put it: replace Src/Main.luau in a project created with this SDK. This is the complete entry file.

    Project setup: add Storage to Capabilities in lui.json. This example requires a custom host that installs storage; the ordinary preview.1 runner cannot provision it. See the capability guide.

    local Window = Instance.new("Window", {
    Title = "LUI example", Size = UDim2.fromOffset(560, 280),
    })
    local Status = Instance.new("TextLabel", {
    Parent = Window, Text = "Ready", Position = UDim2.fromOffset(16, 170),
    Size = UDim2.new(1, -32, 0, 72),
    })
    local Storage = app:GetService("StorageService")
    local Request = Storage:Open(buffer.fromstring("example_note"), nil, function(_, Handle, Failure)
    if Failure or not Handle then Status.Text = "Storage unavailable"; return end
    Storage:Read(buffer.create(0), Handle, function(Bytes, _, ReadFailure)
    if ReadFailure then
    Status.Text = "Read failed"
    elseif Bytes then
    Status.Text = buffer.tostring(Bytes)
    else
    Status.Text = "No saved note yet"
    end
    Handle:Close()
    end)
    end)
    Window.Visible = true

    Expected result: Open returns a NativeRequest immediately; its callback supplies a NativeHandle on success. Close the handle after use. Request:Cancel() can cancel a pending operation, but does not undo completed work.

    • Receive a handle from a native service; do not construct one with Instance.new or invent a pointer value. Backend/toolkit objects remain private.

    Releases this owned resource, returning whether it was closed. Repeated close is safe. The handle is opaque: it is not an OS/toolkit pointer.

    Close() -> boolean
    Full type declaration — for type checking and deeper reference

    The declaration is generated from the SDK. Self is supplied by a colon call; read means the field cannot be assigned. See how to read this reference.

    export type NativeHandle = {
    read Close: (Self: NativeHandle) -> boolean,
    }

    See platform limits before relying on host-specific behavior. The framework design specification and reflection/type sources are deeper engineering references, not extra setup required to build an app.