SuperNode
Widget

Overview

Publish a native home-screen widget snapshot.

Publish a snapshot

Import widget and widget components from supernode/widget. Configure JSX as described in View.

import { Column, DateText, Modifier, Text, widget } from "supernode/widget";

await widget.show({
  views: (
    <Column spacing={8} modifier={Modifier.padding(16)}>
      <Text fontSize={20} fontWeight="bold">SuperNode</Text>
      <Text>{widget.inputValue ?? "Welcome"}</Text>
      <DateText date={new Date()} format="time" prefix="Updated " />
    </Column>
  ),
  options: { refresh: new Date(Date.now() + 30 * 60 * 1000) },
});

widget.show({ views, options? }): Promise<void> renders a ViewChild once, validates it, sends the resulting tree to Android and returns after the host accepts it. The script can then finish. Function components are called directly as pure functions. Use App for Hooks, interactive state updates and TextField input.

Widgets are rendered by Glance, so supernode/widget only provides what Glance can render faithfully. See Components and Modifier for what is available, and View for the comparison with App pages.

Context

PropertyValue
widget.familysmall, medium, large, or extraLarge.
widget.displaySize{ width, height }, in dp.
widget.inputValueOptional configured string.
options.refreshOptional Date requesting the next refresh time.

The host injects context when executing a configured widget. Outside that context, defaults are small, 158 × 158, and an undefined input value. Refresh timing is scheduled by Android and may be delayed by system constraints. An invalid refresh date throws an error.

Validation and errors

Unsupported props fail at type-check time. widget.show() validates the tree again before calling the host and rejects with the path of the offending view, for example when a view imported from supernode/app is mixed in:

widget.show(): Column > TextField[0]: TextField is an app-only view; import widget views from "supernode/widget"

The same check rejects containers with more than 10 children and properties set twice on one modifier chain. Calling a Hook or reading a Context in a widget view throws an error.

Execution

Add a SuperNode widget from the Android launcher and choose its project. The host selects a project script in the order widget:render, widget, start, followed by the project entry file. Each execution receives a private token that routes its output to the correct widget instance. The SDK passes that token automatically.

Calling widget.show from an ordinary SuperNode script validates the view tree and returns success without publishing, which is useful for checking a widget from the terminal. Catch rejected Promises and inspect execution logs when rendering fails.

On this page