useCommand

CommandPalette
stable

Process-wide command palette registry. Uses module-scope state (not provide/inject) so commands can be registered from anywhere — feature code, plugins, background services — without coupling to a Vue tree. Two callers on the same module instance see the exact same reactive list.

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

Entries are deduplicated by id at write time. Calling register() with the same id replaces the previous entry in place so the array length stays stable and watchers on length only see one mutation.

Consumed interfaces

ICommand

API

Return values

Properties and methods exposed by the composable return object.

register
Register a command. Returns an unregister() closure. When called inside a Vue effect scope, the entry is auto-unregistered on scope dispose (component unmount, route leave).
unregister
Drop the entry with the matching id. No-op if the id is unknown.
commands
Reactive read-only view of every registered command, deduplicated by id.
open
Open the global palette singleton.
close
Close the global palette singleton.
isOpen
Reactive open/close state of the global palette singleton.

Usage

Examples

Ready-to-paste usage snippets.

Register a command from a feature component

vue

Open and close the palette programmatically

vue