@csark0812/zustand-expo-devtools
v2.1.5
Published
A new DevTools plugin created by create-dev-plugin
Readme
Zustand Expo DevTools
A DevTools plugin that brings Zustand state debugging capabilities to Expo DevTools, allowing you to inspect and debug your Zustand stores directly in the Expo development environment. This plugin works exactly like the built-in Zustand devtools middleware, with the same API and functionality.
Features
- 🔍 State Inspection - View your Zustand store state in real-time
- 🎯 Action Tracking - Monitor state changes and actions with named actions
- 🔄 Time Travel Debugging - Navigate through state history using Redux DevTools
- 🚀 Expo Integration - Seamlessly integrates with Expo DevTools platform
- 📱 React Native Support - Works with Expo managed workflow
- 🌐 Redux DevTools Core - Leverages Redux DevTools app core for state inspection
- 🏗️ TypeScript Support - Full TypeScript support with proper type definitions
- ⚡ Production Safe - Automatically disabled in production builds
Installation
npm install @csark0812/zustand-expo-devtools
# or
yarn add @csark0812/zustand-expo-devtools
# or
pnpm add @csark0812/zustand-expo-devtoolsAccessing DevTools
To access the DevTools interface:
- Start your Expo development server (
npx expo start) - Open your app in Expo Go or development build
- Press Shift+M in the Expo development menu to open DevTools
- Navigate to the DevTools plugin to inspect your Zustand stores
Quick Start
import { create } from 'zustand';
import { devtools } from '@csark0812/zustand-expo-devtools';
interface CounterState {
count: number;
increment: () => void;
decrement: () => void;
}
const useCounterStore = create<CounterState>()(
devtools(
(set) => ({
count: 0,
increment: () => set((state) => ({ count: state.count + 1 }), false, 'increment'),
decrement: () => set((state) => ({ count: state.count - 1 }), false, 'decrement'),
}),
{
name: 'counter-store', // Optional: name your store for better debugging
}
)
);How It Works
This plugin provides the same functionality as Zustand's built-in devtools middleware, but integrated with Expo's DevTools platform:
- Store Integration: Wrap your Zustand store with the
devtoolsmiddleware (same API as Zustand's built-in devtools) - Expo DevTools: Press Shift+M in your Expo development menu to open DevTools
- DevTools Plugin: Navigate to the DevTools plugin to inspect your stores
- Debug: Inspect state, track actions, and time-travel through your store's history
Configuration Options
interface DevtoolsOptions {
name?: string; // Store name (default: 'zustand')
enabled?: boolean; // Enable/disable devtools (default: true)
anonymousActionType?: string; // Default action name (default: 'anonymous')
store?: string; // Store identifier
}Usage with Actions
For better debugging experience, provide action names when updating state:
const useStore = create<State>()(
devtools(
(set) => ({
// ... your state
updateUser: (user) => set({ user }, false, 'updateUser'),
resetState: () => set(initialState, false, 'resetState'),
}),
{ name: 'user-store' }
)
);Usage with Other Middleware
The plugin works well with other Zustand middleware like immer and persist:
import { create } from 'zustand';
import { immer } from 'zustand/middleware/immer';
import { persist, createJSONStorage } from 'zustand/middleware';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { devtools } from '@csark0812/zustand-expo-devtools';
const useStore = create<State>()(
devtools(
persist(
immer((set) => ({
// ... your state and actions
})),
{
name: 'app-storage',
storage: createJSONStorage(() => AsyncStorage),
}
),
{ name: 'app-store' }
)
);Production Builds
The devtools middleware is automatically disabled in production builds, so you don't need to worry about removing it for production.
Requirements
- Expo SDK 53+
- Zustand 5.0.5+
- React Native / Expo development environment
Development
This repository contains:
/src- The main devtools plugin source code/webui- The DevTools web UI that connects to Redux DevTools Extension/examples/basic- Example Expo app demonstrating usage
To run the example:
cd examples/basic
npm install
npx expo startTo develop the plugin:
# Install dependencies
npm install
# For development (rebuilds on changes)
npm run build:dev
# Build the plugin
npm run build
# Build the web UI
npm run web:export
# Build everything
npm run build:allDevelopment Workflow: After making changes to the plugin source code, run npm run build:dev in the root folder to rebuild the library. This will update the compiled code that the example app uses for testing your changes.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Automated Releases
This repository uses automated versioning and publishing when PRs are merged to main. The version bump type is determined by PR labels:
majorlabel → Major version bump (e.g., 2.0.0 → 3.0.0) - Breaking changesminorlabel → Minor version bump (e.g., 2.0.0 → 2.1.0) - New featurespatchlabel → Patch version bump (e.g., 2.0.0 → 2.0.1) - Bug fixes (default)
To control the release type:
- Add the appropriate label (
major,minor, orpatch) to your PR - If no label is added, it defaults to a
patchrelease - When the PR is merged, the version will be automatically bumped and published to npm
License
MIT © Christopher Sarkissian
Related
- Zustand - 🐻 Bear necessities for state management in React
- Expo DevTools - Expo's debugging and profiling tools
- Redux DevTools - DevTools core integration
Inspiration & Credits
This project was inspired by:
- redux-devtools-expo-dev-plugin - Redux DevTools integration for Expo
- zustand-expo-devtools - Previous Zustand DevTools implementation
Built using:
- Expo DevTools Plugins - Expo's DevTools plugin architecture
