NativeHandle
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.
Example
Section titled “Example”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. Also add "Storage": {"ApplicationId": "com.example.docs"}. 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 = trueExpected 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.
Behavior and limits
Section titled “Behavior and limits”- Receive a handle from a native service; do not construct one with Instance.new or invent a pointer value. Backend/toolkit objects remain private.
Methods
Section titled “Methods”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() -> booleanFull 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,}Availability and deeper reading
Section titled “Availability and deeper reading”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.