New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-devpeek

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-devpeek

A developer tool for debugging React state and local storage

latest
Source
npmnpm
Version
0.1.5
Version published
Maintainers
1
Created
Source

react-devpeek

A developer tool for debugging React state and local/session storage

react-devpeek is a lightweight debugging tool that helps React developers inspect and manipulate state management and browser storage at runtime. It provides an intuitive interface for viewing state snapshots and managing localStorage/sessionStorage directly in your app during development.

React DevPeek

Features

  • 🔍 Storage Inspector: View, edit, and delete localStorage and sessionStorage items
  • 🧩 State Management: Connect to any state management library (Zustand, Redux, MobX, Context API)
  • 🌓 Dark Mode Support: Automatically adapts to system preferences or manual setting
  • 📱 Responsive Design: Draggable panel works on all screen sizes
  • 📤 Export Functionality: Export state and storage data as JSON
  • 🧪 Production Safe: Automatically disabled in production by default

Installation

npm install react-devpeek
# or
yarn add react-devpeek
# or
pnpm add react-devpeek

Basic Usage

Add the DevPeek component to your application's root component:

import ReactDevPeek from "react-devpeek";

function App() {
  return (
    <>
      <YourApp />
      <ReactDevPeek />
    </>
  );
}

Connecting State Adapters

DevPeek can connect to any state management library using adapters:

Zustand Example

import ReactDevPeek from "react-devpeek";
import { useCounterStore } from "./stores/counterStore";
import { useUserStore } from "./stores/userStore";

function App() {
  return (
    <>
      <YourApp />
      <ReactDevPeek
        stateAdapters={[
          {
            name: "Counter Store",
            getState: useCounterStore.getState,
            subscribe: useCounterStore.subscribe,
          },
          {
            name: "User Store",
            getState: useUserStore.getState,
            subscribe: useUserStore.subscribe,
          },
        ]}
      />
    </>
  );
}

React Context API Example

import ReactDevPeek from "react-devpeek";
import { ThemeContext } from "./contexts/ThemeContext";
import { UserContext } from "./contexts/UserContext";

function App() {
  // Create adapters for context
  const themeContextAdapter = {
    name: "Theme Context",
    getState: () => React.useContext(ThemeContext),
    // No subscribe method for Context - DevPeek will poll periodically
  };

  const userContextAdapter = {
    name: "User Context",
    getState: () => React.useContext(UserContext),
  };

  return (
    <>
      <YourApp />
      <ReactDevPeek stateAdapters={[themeContextAdapter, userContextAdapter]} />
    </>
  );
}

Configuration Options

The ReactDevPeek component accepts the following props:

PropTypeDefaultDescription
showInProductionbooleanfalseShow DevPeek in production environments
position'top-left' | 'top-right' | 'bottom-left' | 'bottom-right''bottom-right'Position of the toggle button
theme'light' | 'dark' | 'system''system'UI theme
defaultOpenbooleanfalseOpen the panel by default
stateAdaptersStateAdapter[][]Array of state adapters to connect
enableLocalStoragebooleantrueEnable localStorage monitoring
enableSessionStoragebooleantrueEnable sessionStorage monitoring

StateAdapter Interface

interface StateAdapter {
  // Display name for the adapter
  name: string;

  // Function that returns the current state
  getState: () => any;

  // Optional subscription function that calls a listener when state changes
  // Should return a function to unsubscribe
  subscribe?: (listener: () => void) => (() => void) | void;
}

Advanced Usage

Custom Positioning

<ReactDevPeek position="top-left" />

Theming

// Set theme explicitly
<ReactDevPeek theme="dark" />

// Use system preference
<ReactDevPeek theme="system" />

Controlling Visibility

const [isDevToolOpen, setDevToolOpen] = useState(false);

<ReactDevPeek defaultOpen={isDevToolOpen} />;

Selective Storage Monitoring

// Only monitor localStorage, not sessionStorage
<ReactDevPeek enableSessionStorage={false} />

// Only monitor sessionStorage, not localStorage
<ReactDevPeek enableLocalStorage={false} />

Development

To develop locally:

  • Clone the repository

    git clone https://github.com/Socdev-africa/react-devpeek.git
    cd react-devpeek
    
  • Install dependencies

    npm install
    
  • Run the demo app

    npm run demo
    
  • Build the library

    npm run build
    
  • Run tests

    npm test
    

Demo

To see a live demo of React DevPeek:

# Clone the repository
git clone https://github.com/Socdev-africa/react-devpeek.git

# Navigate to the project
cd react-devpeek

# Install dependencies
npm install

# Run the demo
npm run demo

This will start a development server with a demo application showcasing various features of React DevPeek.

Browser Support

React DevPeek supports all modern browsers including:

  • Chrome
  • Firefox
  • Brave
  • Safari
  • Edge

License

MIT © SocDev Africa

Contributors

Acknowledgements

Keywords

react

FAQs

Package last updated on 08 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts