Jotai DevTools
🚀 Features
- Debug 🐞 atom values with ease
- ⏳ Time-travel through your atoms and find bugs faster than before
(recommended jotai
>=2.2.0
) - Out-of-the-box 🔌 support for async/suspendible 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 (requires Jotai
>=2.0.3
) - ✅ Tree-shakable and built for non-production environments
- ✅ Parses all the JavaScript values with JSON Tree view
- ✅ Diff checking with additions and deletion highlights
📺 Preview
☝️ Prerequisites
- Jotai version
>=1.11.0
(highly recommended to use 2.x.x
) - React version
>=17.0.0
📦 Setup
(See complete setup guide for UI-based devtools below)
yarn add jotai-devtools
npm install jotai-devtools --save
✨ UI DevTools
Enhance your development experience with the UI based Jotai DevTool
Babel plugin setup - (Optional but highly recommended)
Use Jotai babel plugins for optimal debugging experience. Find the complete
guide on jotai.org
Eg.
{
"plugins": [
"jotai/babel/plugin-react-refresh",
"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.
const nextConfig = {
transpilePackages: ['jotai-devtools'],
};
module.exports = nextConfig;
Available props
type DevToolsProps = {
isInitialOpen?: boolean;
store?: Store;
theme?: 'dark' | 'light';
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
nonce?: string;
options?: {
shouldShowPrivateAtoms?: boolean;
shouldExpandJsonTreeViewInitially?: boolean;
timeTravelPlaybackInterval?: number;
snapshotHistoryLimit?: number;
};
};
Provider-less
import { DevTools } from 'jotai-devtools';
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>
);
};
Hooks
Detailed documentation is available on
https://jotai.org/docs/api/devtools
import {
useAtomsSnapshot,
useGotoAtomsSnapshot,
useAtomsDebugValue,
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.
-
Remove @emotion/react
from your dependencies
yarn remove @emotion/react
npm uninstall @emotion/react
-
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
-
Install this package
npm install jotai-devtools --save
yarn add jotai-devtools
-
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