-
Notifications
You must be signed in to change notification settings - Fork 0
DevTools
ABCrimson edited this page Mar 11, 2026
·
2 revisions
useCommandDevtools() exposes the command machine state to browser developer tools for debugging.
import { Command, useCommandDevtools } from 'modern-cmdk/react';
function MyCommand() {
useCommandDevtools('main-palette');
return (
<Command>
<Command.Input />
<Command.List>
<Command.Item>Action</Command.Item>
</Command.List>
</Command>
);
}In development (__DEV__), the hook:
- Stores the machine state snapshot in
globalThis.__CRIMSON_COMMAND_DEVTOOLS__(aMap<string, object>) - Dispatches
crimson-command-devtoolsCustomEventon every state change
// Read all active command palettes
globalThis.__CRIMSON_COMMAND_DEVTOOLS__
// Listen for state changes
window.addEventListener('crimson-command-devtools', (e) => {
console.log(e.detail);
});The hook is a no-op in production builds. The __DEV__ guard ensures zero overhead.