Skip to main content
The SDK does not impose a style. The start file can register at the top level, or export something the app starts for you, and UI can be function or class components.

The start file

All four of these are equally supported.

Rules that apply to all of them

  • onLoad may be async. The expansion counts as started once it resolves.
  • If the start file or onLoad throws, everything already registered is removed, so nothing is left half-installed. The error and its location show on the Expansions page.
  • onUnload on an instance takes priority over an exported onUnload.
  • You rarely need onUnload: everything registered through sdk is removed automatically. Use it for things the SDK does not know about, such as flushing your own buffer.

Components

Both work anywhere a component is accepted: pages, editors, creators, injections and item-editor modules. As in React generally, hooks such as useProjectState only work inside function components; a class component keeps its own state, or reads and writes through sdk.

JavaScript or TypeScript

Both are first class, and you can mix them in one expansion. TypeScript gets you autocomplete and type checking in the editor; at load the types are stripped without being checked, so a type error never stops your expansion from running.