Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

jotai-devtools

jotaijs418.2kMIT0.12.0TypeScript support: included

A powerful toolkit to enhance your development experience with Jotai

jotai, devtools, debugger, react, state, management, redux devtools

readme

Jotai DevTools

Build Status Version Version

🚀 Features

  • Debug 🐞 atom values with ease
  • ⏳ Time-travel through your atoms and find bugs faster than before
  • Out-of-the-box 🔌 support for async/suspendable atoms
  • Built-in Dark mode 🌗
  • ✅ Supports custom store
  • ✅ Works with provider-less mode
  • ✅ Works with Next.js
  • ✅ Supports custom nonce for CSP
  • ✅ Hides private atoms with ability to configure
  • ✅ Parses all the JavaScript values with JSON Tree view
  • ✅ Diff checking with additions and deletion highlights

📺 Preview

Jotai DevTools Screenshot

☝️ Prerequisites

  • Jotai version >=v2.12.3
  • React version >=17.0.0

📦 Setup

(See complete setup guide for UI-based devtools below)

# yarn
yarn add jotai-devtools

# npm
npm install jotai-devtools --save

✨ UI DevTools

Enhance your development experience with the UI based Jotai DevTool

Demo

Use Jotai babel plugins for optimal debugging experience. Find the complete guide on jotai.org

Eg.

{
  "plugins": [
    // Enables hot reload for atoms
    "jotai/babel/plugin-react-refresh",
    // Automatically adds debug labels to the atoms
    "jotai/babel/plugin-debug-label"
  ]
}

Next JS setup

You may skip this section if you're not using Next.js.

Enable transpilePackages for the UI CSS and components to be transpiled correctly.

// next.config.ts

const nextConfig = {
  // Learn more here - https://nextjs.org/docs/advanced-features/compiler#module-transpilation
  // Required for font css to be imported correctly 👇
  transpilePackages: ['jotai-devtools'],
};

module.exports = nextConfig;

Available props

type DevToolsProps = {
  // Defaults to false
  isInitialOpen?: boolean;
  // pass a custom store
  store?: Store;
  // Defaults to light
  theme?: 'dark' | 'light';
  // Defaults to 'bottom-left'
  position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
  // Custom nonce to allowlist jotai-devtools specific inline styles via CSP
  nonce?: string;
  // We recommend keeping these options static. i.e. set it only once. Avoid connecting it to re-renderable state
  options?: {
    // Private atoms are used internally in atoms like `atomWithStorage` or `atomWithLocation`, etc. to manage state.
    // Defaults to `false`
    shouldShowPrivateAtoms?: boolean;
    // Expands the JSON tree view on initial render on Atom Viewer tab, Timeline tab, etc.
    // Defaults to `false`
    shouldExpandJsonTreeViewInitially?: boolean;
    // The interval (in milliseconds) between each step of the time travel playback.
    // Defaults to `750ms`
    timeTravelPlaybackInterval?: number;
    // The maximum number of snapshots to keep in the history.
    // The higher the number the more memory it will consume.
    // Defaults to `Infinity`. Recommended: `~30`
    snapshotHistoryLimit?: number;
  };
};

Provider-less

import { DevTools } from './JotaiDevTools';
import 'jotai-devtools/styles.css';
const App = () => {
  return (
    <>
      <DevTools />
      {/* your app */}
    </>
  );
};

With Provider

import { createStore } from 'jotai';

import { DevTools } from 'jotai-devtools';
import 'jotai-devtools/styles.css';

const customStore = createStore();

const App = () => {
  return (
    <Provider store={customStore}>
      <DevTools store={customStore} />
      {/* your app */}
    </Provider>
  );
};

Tree-shaking

Jotai DevTools is currently only available in development mode. We're changing this in the future to allow it to be used in production as well.

Therefore, we recommend wrapping the DevTools in a conditional statement and tree-shake it out in production to avoid any accidental usage in production.

Vite

import { DevTools } from 'jotai-devtools';
import css from 'jotai-devtools/styles.css?inline';

const JotaiDevTools = () =>
  process.env.NODE_ENV !== 'production' ? (
    <>
      <style>{css}</style>
      <DevTools />
    </>
  ) : null;

const App = () => {
  return (
    <>
      <JotaiDevTools />
      {/* your app */}
    </>
  );
};

NextJS

Create a DevTools.tsx file in your project and export the DevTools component.

import 'jotai-devtools/styles.css';
export { DevTools } from 'jotai-devtools';

Then, in your app, import the DevTools component conditionally.

import dynamic from "next/dynamic";
import type { ComponentType } from "react";
import type { DevToolsProps } from "jotai-devtools";

let DevTools: ComponentType<DevToolsProps> | null = null;

if (process.env.NODE_ENV !== "production") {
  DevTools = dynamic(
    () => import("./DevTools").then((mod) => ({ default: mod.DevTools })),
    { ssr: false }
  );
}

const App = () => {
  return (
    <>
      {DevTools && <DevTools />}
      {/* your app */}
    </>
  );

Hooks

Detailed documentation is available on https://jotai.org/docs/api/devtools

import {
  useAtomsSnapshot,
  useGotoAtomsSnapshot,
  useAtomsDebugValue,
  // Redux devtool hooks
  useAtomDevtools,
  useAtomsDevtools,
} from 'jotai-devtools';

Migration guides

Migrate ƒrom @emotion/react to native CSS

With the latest release, Jotai DevTools no longer depends on @emotion/react and is replaced it with native CSS.

  1. Remove @emotion/react from your dependencies

    # yarn
    yarn remove @emotion/react
    
    # npm
    npm uninstall @emotion/react
  2. Replace @emotion/react with jotai-devtools/styles.css in your code

Note that this css file may get included in your production builds please import it conditionally if you want to avoid that.

import { DevTools } from 'jotai-devtools';
+ import 'jotai-devtools/styles.css';

Migrate Jotai to V2

Find the official migration guide on jotai.org

Migrate jotai/react/devtools to jotai-devtools

  1. Install this package

    # npm
    npm install jotai-devtools --save
    
    # yarn
    yarn add jotai-devtools
  2. Update imports from jotai/react/devtools to jotai-devtools

    import {
     useAtomsSnapshot,
     useGotoAtomsSnapshot,
     useAtomsDebugValue,
     // Redux devtool integration hooks
     useAtomDevtools,
     useAtomsDevtools,
    - } from 'jotai/react/devtools';
    + } from 'jotai-devtools';

Inspirations

Redux DevTools React Query DevTools

Other announcements

First announcement

changelog

Changelog

0.11.0 (2025-02-19)

  • fix: drop support for jotai store v1 (#173) (5c19880), closes #173
  • fix: guard restore action with isTimeTravelling atom (#174) (8a2d303), closes #174
  • test(TimeTravel): async atom snapshot history (#170) (efd498b), closes #170
  • chore: update dependencies (#172) (32dec78), closes #172
  • docs: fix readme. (#162) (12adbab), closes #162

0.10.1 (2024-08-09)

Bug Fixes

  • atom toString includes debugLabel in dev mode (#156) (609bd5a)
  • react warnings on async atom read in v2 store (#160) (b27d779)

0.10.0 (2024-06-07)

Features

0.9.1 (2024-04-24)

Bug Fixes

  • remove global styles from final css build (#139) (13e9d60)

0.9.0 (2024-04-16)

Features

  • remove dependency to @emotion/react + adopt native css solution (#129) (0b99ce0)

0.8.0 (2024-02-20)

Features

0.7.1 (2023-12-04)

Bug Fixes

  • defer setAtom in subscribers of store change during main render to next micro task (#109) (2cdc81d)

0.7.0 (2023-10-14)

Features

0.6.3 (2023-10-01)

Bug Fixes

  • add trigger button to global css (#98) (1033c5e)

0.6.2 (2023-08-21)

Bug Fixes

  • update jsondiffpatch to resolve process.platform undefined error (#93) (19f885d)

0.6.1 (2023-08-02)

Bug Fixes

0.6.0 (2023-06-16)

Features

0.6.0-next.0 (2023-06-15)

Features

  • add time travel feature (53b916a)
  • hardcode locale to en-US for now (312deff)

Bug Fixes

  • create-timestamp.ts: add default locale (10c2ef8)

Refactors

  • RecordHistory.tsx: update tooltip content (04187a2)

0.5.3 (2023-05-11)

Features

Bug Fixes

  • add backwards compatible store support for <=2.1.0 (#70) (f1f6f79)

Refactors

  • cosmetic update streamline border radius (#71) (7f8e70c)
  • extract action list item to its own component (#75) (e218e5f)

0.5.2 (2023-05-01)

Bug Fixes

  • avoid running preinstall scripts on userland (#67) (2c49877)

0.5.1 (2023-04-30)

Bug Fixes

0.5.0 (2023-04-30)

Bug Fixes

  • generate esm modules with process.env.NODE_ENV (#60) (0d07f94)

Features

0.4.0 (2023-03-29)

Bug Fixes

  • move @emotion/react to peer dependency (#42) (b4cdb50)
  • prevent adding padding to body (#51) (98b34fe)

Features

  • cache user-set shell height for optimal UX (#43) (a2d5ea6)

0.3.1 (2023-03-12)

Bug Fixes

0.3.0 (2023-03-06)

Bug Fixes

  • improve atom list stability + remove deep parse feature (fe82bfe)

0.3.0-next.4 (2023-03-02)

Bug Fixes

  • bundle in fonts for better stability (236cd75)
  • fonts css (be8c16c)
  • use JetBrains mono fonts on NavLink (68cbe5a)

Features

  • add option to display private atoms (d1875ee)

0.3.0-next.3 (2023-02-17)

Bug Fixes

  • infer options type from Jotai (8ddad63)
  • use exactOptionalPropertyTypes (6c9cbdf)

Features

  • add custom style nonce + remove global normalized styles (10d3c4a)

0.3.0-next.2 (2023-02-12)

Features

0.3.0-next.1 (2023-02-10)

Bug Fixes

  • handle atom containing undefined values (c086a75)
  • inject react shim to the build (a20a235)

Features

  • make raw and parse value copyable (5348337)

0.3.0-next.0 (2023-02-07)

Features

  • ui-devtools: initial commit (7c38133)

0.2.0 (2023-02-01)

0.2.0-next.1 (2023-01-17)

Bug Fixes

0.2.0-next.0 (2023-01-16)

Bug Fixes

  • utils: pass options through base hooks (#17) (d129ea6)
  • utils: types for /utils entry point (#18) (743d984)

0.2.0-Alpha.0 (2023-01-14)

Features

Miscellaneous Chores

0.1.0 (2023-01-10)

Miscellaneous Chores

0.0.1-alpha.0 (2023-01-10)

Miscellaneous Chores

0.0.1-alpha (2023-01-09)

Features

  • migrate devtools for Jotai v1 API (#5) (2c2d169)