Core registry and hooks for React State Inspector
npm install react-state-inspector-devtoolsA lightweight, runtime state inspector for React.
Inspect and edit component state live โ directly from your app.


---
react-state-inspector-devtools is a dev-only React tool that lets you:
- ๐ See which components are currently mounted
- ๐ Inspect their internal state (useState)
- โ๏ธ Edit state values live from a floating UI panel
- โก Observe UI updates instantly
No browser extensions.
No React DevTools dependency.
Just drop it into your app.
---
React DevTools are great โ but sometimes you want:
- ๐ฅ๏ธ State inspection inside the app
- ๐งช A tool that works in embedded environments, previews, sandboxes
- ๐จ A way to poke state values quickly while designing UI
- โ๏ธ Zero setup, zero configuration
> This tool is optimized for developer experience, not production analytics.
---
``bash`
npm install react-state-inspector-devtools
or
`bash`
pnpm add react-state-inspector-devtools
or
`bash`
yarn add react-state-inspector-devtools
---
`tsx
import { StateInspectorProvider, StateInspectorUI } from "react-state-inspector-devtools";
export function AppRoot() {
return (
{import.meta.env.DEV &&
);
}
`
> โ ๏ธ Important:
> This tool is intended for development only.
> Always gate it behind DEV / NODE_ENV !== "production".
Replace useState with useInspectableState:
`tsx
import { useInspectorComponent, useInspectableState } from "react-state-inspector-devtools";
export function CounterCard() {
const inspector = useInspectorComponent("CounterCard");
const [count, setCount] = useInspectableState(inspector, "count", 0, {
type: "number",
min: 0,
max: 999,
step: 1,
});
return (
That's it.
The component and its state will appear in the inspector UI.
---
๐ช The Inspector UI
- Appears as a floating button in the bottom-right corner
- Opens a panel with:
- Left: Mounted components list
- Right: Editable state values
- State changes update the UI immediately
$3
| Type | Editor |
| --------- | ---------------------------------- |
|
boolean | โ
Checkbox |
| number | โ
Number input (min / max / step) |
| text | โ
Text input (with placeholder) |
| select | โ
Dropdown |
| json | โ
JSON editor |---
๐งฉ API Reference
$3
Wraps your app and controls whether the inspector is active.
`tsx
{children}
`| Prop | Type | Description |
| ---------- | ----------- | ---------------------------------------- |
|
enabled | boolean | Controls whether the inspector is active |
| children | ReactNode | Your application |---
$3
Renders the floating inspector overlay.
`tsx
`---
$3
Registers a component instance with the inspector.
`tsx
const inspector = useInspectorComponent("ProfileForm");
`- Creates a stable component identity
- Must be called once per component
- The
label appears in the component list---
$3
Drop-in replacement for
useState that registers state with the inspector.`tsx
const [value, setValue] = useInspectableState(
inspector,
key,
initialValue,
meta?
);
`| Parameter | Type | Description |
| -------------- | ----------------------- | ---------------------------------------- |
|
inspector | InspectorComponentRef | Returned from useInspectorComponent |
| key | string | State name shown in the UI |
| initialValue | T | Initial state value (same as useState) |
| meta | InspectableMeta | Optional UI hints for the editor |---
๐ Meta Options
The
meta parameter controls how the state is rendered in the inspector UI:$3
`tsx
{
type: "boolean";
}
`$3
`tsx
{ type: "number", min: 0, max: 100, step: 5 }
`$3
`tsx
{ type: "text", placeholder: "Enter name..." }
`$3
`tsx
{
type: "select",
options: ["small", "medium", "large"],
}// Or with labels
{
type: "select",
options: [
{ label: "Small", value: "sm" },
{ label: "Medium", value: "md" },
{ label: "Large", value: "lg" },
],
}
`$3
`tsx
{
type: "json";
}
`> ๐ก Tip: If you don't provide
meta, the type is automatically inferred from the initial value.---
๐งช Examples
$3
`tsx
export function FlagsPanel() {
const inspector = useInspectorComponent("FlagsPanel"); const [isAdmin, setIsAdmin] = useInspectableState(inspector, "isAdmin", false, {
type: "boolean",
});
const [betaUser, setBetaUser] = useInspectableState(inspector, "betaUser", true, {
type: "boolean",
});
return (
);
}
`$3
`tsx
export function VariantPicker() {
const inspector = useInspectorComponent("VariantPicker"); const [variant, setVariant] = useInspectableState(inspector, "variant", "M", {
type: "select",
options: ["S", "M", "L", "XL"],
});
return (
);
}
`$3
`tsx
export function ProfileForm() {
const inspector = useInspectorComponent("ProfileForm"); const [name, setName] = useInspectableState(inspector, "name", "", {
type: "text",
placeholder: "Name",
});
const [email, setEmail] = useInspectableState(inspector, "email", "", {
type: "text",
placeholder: "Email",
});
return (
setName(e.target.value)} placeholder="Name" />
setEmail(e.target.value)} placeholder="Email" />
);
}
`---
๐ Production Safety
- โ
The inspector does nothing when
enabled={false}`> โ ๏ธ Still, do not ship it enabled in production.
---
- ๐จ UI development & tweaking
- ๐ Design system work
- ๐ Component libraries
- ๐ผ๏ธ Embedded previews
- ๐ง Internal tools
- ๐ค Demos & presentations
---
- React DevTools
- Redux DevTools
- In-app debug overlays
โฆbut intentionally simpler and runtime-focused.
---
MIT
---
This is a V1 devtool built for real-world usage.
Ideas, issues, and PRs are welcome!
---
- npm