Inline Renderer

@theaiplatform/miniapp-sdk/inline-renderer defines the shared browser contract for compact package UI that the host mounts inside an isolated iframe. Link unfurls and chat blocks use this contract with different host-sealed payloads.

Mount a Renderer

import type { TapInlineRendererModule } from '@theaiplatform/miniapp-sdk/inline-renderer';

const renderer: TapInlineRendererModule<{ title: string }> = {
  mount(root, context) {
    root.textContent = context.payload.title;
    return { unmount: () => root.replaceChildren() };
  },
};

export default renderer;

The host owns the frame, theme updates, declared action dispatch, declared resource delivery, and teardown. A renderer cannot fetch arbitrary network resources, create WebRTC peer connections, or invoke undeclared host actions through this contract.

The hardened renderer bootstrap requires Miniapp SDK 0.16.0. Rebuild packages created with an earlier SDK before installing them on a host that enforces this boundary.

Use the more specific /chat-renderer and /link-unfurl exports when authoring those contribution types.

Public Export Contract

ExportPurposeInputs and resultLifecycle and errorsWorking example
TapInlineRendererThemeValueRestricts the live host-selected renderer theme to light or dark.Supplies one light or dark string from the current theme snapshot.Type only; theme changes are cosmetic and never grant package authority.Mount a renderer
TapInlineRendererThemeExposes the current renderer theme and later cosmetic theme changes.getSnapshot returns a theme value and subscribe returns cleanup.The value can change while mounted; remove every subscription during unmount.Mount a renderer
TapInlineRendererActionRepresents one host-authorized action admitted by the contribution.Exposes an ID, label, and invoke with an optional sealed-payload pointer.Missing actions are unavailable and invalid payload pointers fail closed.Mount a renderer
TapInlineRendererResourcesResolves host-authorized resources admitted for the current renderer.read accepts a declared resource ID and resolves a read-only typed value.Each declared resource is fetched at most once for the current mount.Mount a renderer
TapInlineRendererMountContextSupplies exact package identity and the renderer's least-authority data.Contains immutable identity, payload, theme, action, and resource fields.The context belongs to one mount and must not be retained after unmount.Mount a renderer
TapInlineRendererMountDefines the optional cleanup handle returned by a renderer mount.Contains an unmount function that returns void or a promise.Cleanup removes renderer-owned listeners, subscriptions, work, and rendered nodes.Mount a renderer
TapInlineRendererModuleDefines the default module exported by an inline-renderer target.mount receives an element and typed context, then returns optional cleanup.The host mounts lazily and retains its static fallback when rendering fails.Mount a renderer