Skip to content
react-global-state-hooks

DevTools

Inspect stores, edit state, time travel and follow actions with the Chrome extension.

GuideBetaTypeScriptTry an example
React Global States DevToolsChrome extension for react-global-state-hooks

The DevTools extension connects to your stores in development so you can see what changes and when.

Install the extension for Chrome

What it does

  • Inspect every global store and context in real time.
  • Edit state from the panel and watch the app respond.
  • Time travel to an earlier state.
  • Track actions to see which one changed the state.
  • Drive it from a terminal or a coding agent with rgsh.

Try it on this website

This website is already connected to DevTools. Try the extension on the live demos before adding anything to your own project. You only need the Chrome extension.

  1. Install the Chrome extension (opens in a new tab).
  2. Open the homepage demo. Open Chrome DevTools on that tab and select the react-global-state-hooks panel.
  3. Reload the page with the panel open, then select the profile store.
  4. Change the name or click a button in the demo. Watch the state update in the panel, then try editing a value there and see the demo respond.

You can also inspect the stores behind the interactive examples. This public demo site intentionally includes the debug integration so you can explore it hands-on. For your own app, keep the integration in development builds as described below.

Connect your app

Import the debug entry once, at the very top of your entry file, before React and before any module that creates a store. It patches the library as stores are created, so stores created before it are not tracked.

main.tsx
// main.tsx
import 'react-global-state-hooks/debug';

import { createRoot } from 'react-dom/client';
import { App } from './App';

Open the panel

  1. Run your app in development.
  2. Open Chrome DevTools and select the extension’s panel for your tab.
  3. Reload the page with the panel open. Reloading after the panel exists avoids initial synchronization problems.
  4. Your stores appear with their names and current state.

Give stores a name option so they are easy to find in the panel.

Drive it from a terminal

react-global-state-hooks, react-hooks-global-states and react-native-global-state-hooks each install an rgsh command. It talks to the panel, so you can watch actions, read state and change state without leaving the terminal.

terminal
npm i -D ws        # rgsh needs it to talk to the extension
npx rgsh --list    # every store DevTools knows about
npx rgsh --help    # everything rgsh can do

Your app must import the debug entry and the panel must be open on the app’s tab. The port is 7787 by default and has to match the panel under gear > Terminal connection.

terminal
npx rgsh --store todos                        # stream one store's actions and state changes
npx rgsh state todos                          # read a store's state and metadata
npx rgsh action todos add "Write the docs"    # run an action
npx rgsh patch todos '{"filter":"done"}'      # merge JSON into the state

If ws is missing, rgsh tells you and prints the install command.

Use it from a coding agent

A coding agent that can run shell commands can use rgsh on the app you have open in Chrome, so it checks what its change did instead of guessing from the source.

terminal
npx rgsh --list                                    # find the store and its action names
npx rgsh action todos add "Write the docs"         # run it; prints the state changes, then exits
npx rgsh state todos todos[0].done                 # read the value back
  • Each action, patch and set prints the resulting block (state changes as path: before → after, the result or the error, and the duration) and exits, so the output is easy to read from a script or an agent.
  • Exit codes: 0 done, 1 failed (unknown store or action, not allowed, the action threw), 2 no store given and no terminal, 3 sent but the page reported nothing within --timeout.
  • An unknown store name is answered with the stores that do exist.
  • Arguments are JSON data and nothing the terminal sends is evaluated. rgsh listens on 127.0.0.1 only.
  • rgsh works on store state and actions. It does not click or type in the page.

A tour of the panel

Explore the extension connected to this repository’s playground, from the full panel to individual actions and state changes.

The whole Chrome DevTools window in the light theme, with the react-global-state-hooks panel open on the counter store: the store list, its logs, and the details of one change.
The whole DevTools window. The extension lives in its own DevTools panel. Stores on the left, the logs of the selected store in the middle, and what one change did on the right.
The panel’s numbered list of global states and contexts, with the counter store selected.
Every store, in one list. All global states and contexts in the app, numbered so you can jump to them. Contexts are labelled.
The logs list of the counter store: the initialize record and four setState records.
Logs of the selected store. The initialize step and each setState call, in order, with timestamps. Restore, copy or download a state from a row’s menu.
The details pane for a selected log, showing the resulting state and how the state changed.
What a change did. Select a log to see the resulting state and how the state changed compared with before.
The State tab of the counter store: the current state and the editor used to set a new state.
View and edit the state. The State tab shows the current value of the store and lets you set a new one from an editor.
The logs pane with the display set to time logs, listing the records in time order.
Logs in time order. Switch the display from groups to time logs to read everything that happened, oldest to newest.
The logs of the todos store grouped by action, showing the add action.
Actions, by name. For a store with actions, changes are grouped under the action that made them, such as add on the todos store.
The Actions tab of the todos store.
The Actions tab. The actions of the selected store, ready to run from the panel.
The “Restore this state?” confirmation dialog with Cancel and Restore buttons.
Restore an earlier state. Restoring asks for confirmation, then sets the app back to that saved state.
The playground app, a page of cards for the counter, todos and other stores that the panel is connected to.
The app being inspected. The playground in this repository. Every card is backed by a global store or a context.

Captured from the live playground with the extension, in the light theme, against library version 16.0.4-beta.

Documentation
↑↓ Navigate ↵ Open Esc CloseRGSH docs
Get started

Shared state. Precise subscriptions.
Built-in DevTools.