Skip to main content
Import hooks from @1upvision/sdk:

useExtensionStorage

The main hook for reading and writing data. Storage is persisted on the server and syncs in real-time between all targets (editor, layer, interactive page).

Basic Usage

Real-Time Sync

When you call setStorage in any target, all other targets update automatically:
  1. Streamer toggles a switch in the editor panel
  2. The value is persisted to the server
  3. The OBS layer receives the update and re-renders
No websocket setup, no polling, no extra code. It just works.
setStorage replaces the entire storage object. Always spread the existing storage when updating a single key:

useVisionState

useVisionState is a key-scoped state hook backed by extension storage. Use it when you want useState-style ergonomics without manually spreading the entire storage object on every update.

Example

When to use which

  • useExtensionStorage: when you want to read/write the whole storage object
  • useVisionState: when you want one key with useState-style updates

useExtensionContext

Returns metadata about the running extension instance. Useful for rendering different UIs per target or for debugging.
Returns null until the extension is initialized, then:

Render Different UI per Target

If your targets share very little UI, it’s usually cleaner to use separate entry point files (admin.tsx, layer.tsx, interactive.tsx) instead of branching with useExtensionContext.

useQuery and useMutation

If your extension uses server functions, two additional hooks are available for calling them from the client:

useQuery

Calls a server query function by name. Returns the data, loading state, and error.

useMutation

Calls a server mutation or action function by name. Automatically invalidates active queries on success.

Which hook for which function type

Using the wrong hook causes a FUNCTION_NOT_FOUND error at runtime. For example, calling a mutation with useQuery will fail.
See Server Functions for full details on defining functions.