FRAMEWORKExperimental — not for production

API guide

Public capability imports, ownership, errors, and resource lifetimes.

Import application APIs from @legendapp/spark/<feature>. The single SDK archive includes private implementation modules; applications should not install or deep-import them. Hooks, imperative operations, and public types share their capability entry point.

Capability entry points

Public pathResponsibilityGuide
/appApp context, events, activation, quit guardsDocuments and lifecycle
/app/documentsFile/URL requests, recent history, document controllers and reload watchesDocuments
/windows, /windows/macosWindows, displays, cursor, geometry, React roots, native macOS chromeWindows
/menus, /context-menu, /trayOwned app menus, native popups and tray itemsMenus
/shortcuts, /global-shortcuts, /shortcuts/commands, /shortcuts/keyboardAccelerators, command routing, persisted bindings and low-level keyboard eventsKeyboard shortcuts
/dialogsOpen/save panels, message dialogs and confirmationFiles and dialogs
/filesPaths, directories, byte/stream/positional IO, watches, scanning, TrashFiles
/settings, /settings/observable, /secure-storageJSON settings, Legend State persistence and selected SecureStore methodsSettings
/settings/windowNormal/virtualized settings-window composition and optionsNative UI
/clipboard, /linksClipboard formats and external URLs/pathsDesktop integrations
/drag-dropNative drag sources and drop destinations with generic payloadsDrag and drop
/notifications, /systemPermissions/local notifications, Dock/taskbar, login startup and powerDesktop integrations
/processesChild processes and app-supplied helper executablesDesktop integrations
/sqlite, /webviewSpark-owned database and embedded browser contractsDesktop integrations
/audio, /auth-sessionAsync players/media sessions and prepared browser-auth sessionsDesktop integrations
/updatesNative whole-app update status, initiation, preferences and eventsPackaging and updates
/ui, /ui/uniwind, /ui/classnamesCommon native controls and optional styling integrationsNative UI
/markdown, /htmlRead-only rich text, controlled inputs, and editable previewsRich text
/ui/search, /ui/sidebar, /ui/split-view, /ui/swipe, /ui/glass, /ui/symbolSpecialized macOS viewsNative UI
/ai, /ai/codexInstalled AI CLI execution and optional macOS Codex supervisorAI execution
/contracts, /diagnosticsShared error/availability/resource types and explicit diagnostic utilitiesShared contracts

Support varies by platform. Check feature-specific availability, permissions, and platform limits.

Shared contracts

Spark-owned commands generally resolve void; data has explicit result types. Expected cancellation, veto, and nonzero process exit are results. Operational failures reject with SparkError; branch on code rather than parsing messages. cause retains underlying failures. Availability is advisory and separate from permissions.

Unknown option keys reject with E_UNSUPPORTED_OPTION, including unknown keys whose value is undefined. Promise operations reject validation failures; synchronous utilities throw. Omission leaves update fields unchanged; null only clears declared nullable fields. Check each operation's merge/replace rules.

Subscriptions expose synchronous remove(). Async registrations resolve to a handle with asynchronous remove(). Resource-specific cleanup uses close(), remove(), terminate(), or dismiss() according to its meaning. Stop observing when the owner ends, await required cleanup, and retain failed handles for supported retry. Concurrent cleanup joins rather than starting duplicate removals. Hooks handle late setup completions and expose cleanup-error callbacks where applicable.

Time is explicit: timeoutMs/Unix timestamps use milliseconds; audio positions and notification delays use seconds. File/process bytes are Uint8Array. Native paths, URLs, and base64 are distinct data forms.

Ecosystem boundaries

Spark owns the supported SQLite, WebView, audio, UI, and desktop contracts. Their backend objects stay private. Selected Clipboard, Linking, and SecureStore methods follow Expo semantics; that does not promise complete Expo-package compatibility.

Legend State observables, React Native, Runtimes, Uniwind, and other ecosystem libraries retain their own APIs. Use upstream imports for capabilities beyond Spark's subset and define resource ownership when mixing integrations.

Tooling and metadata exports

These are not application runtime capabilities:

PathsUse
/config, /schema.json, /config-plugin, /expo-configTyped configuration, schema and Expo composition
/metro, /nativeMetro and native discovery
/runtime-entry, /metro-gate, /init-templateGenerated-project runtime/bootstrap integration
/cliCLI executable entry
/package.jsonPackage metadata

For changes to older imports and contracts, see migration.

Contributors should follow the repository's API design rules when adding APIs or replacing backends.