Skip to content

peter-byun/recoil-inspector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Recoil Inspector ๐Ÿ” ยท GitHub license PRs Welcome

Ever had a hard time debugging a Recoil state update bug?
Try Recoil Inspector to visualize which components are using which states, and get to the source of the bug quickly.
It supports both Next.js 13 and 14.

Contents

Demo ๐Ÿ“ผ

demo.mp4

Features โšก๏ธ

  • State and Components Visualization โš›๏ธ
    • See which components are referencing which Recoil states and props.
  • State Changes History โบ
    • See how states have been changed over time. You can compare two changes to see exactly which properties have been updated, deleted, or added.
  • Enabled Only On Development Mode
    • It is activated only when process.env.NODE_ENV is development, and to avoid increasing your application's bundle size, it is lazily loaded only when enabled.

Installation Guide ๐Ÿ’ฟ

  1. Install the React Devtool extension if you have not already.

  2. Install the NPM package.

    npm install recoil-inspector
  3. Import the package in your entry point like the below examples.

Next.js App Router

// layout.ts
// NOTE: "use client" will not be needed in the future. We will keep the "use client" directive in the RecoilInspector component.
'use client';

import { RecoilInspector } from 'recoil-inspector';

if (process.env.NODE_ENV === 'development') {
  import('recoil-inspector/public/index.css');
}

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html>
      <RecoilRoot>
        <body>
          <RecoilInspector />
          {children}
        </body>
      </RecoilRoot>
    </html>
  );
}

Next.js Pages

import { RecoilInspector } from 'recoil-inspector';

if (process.env.NODE_ENV === 'development') {
  import('recoil-inspector/public/index.css');
}

export function Layout({ children }: { children: ReactNode }) {
  return (
    <RecoilRoot>
      {children}
      <RecoilInspector />
    </RecoilRoot>
  );
}

Acknowledgement

This project is inspired by many other great devtools, including Redux DevTools, React Developer Tools, Recoil Dev Tools, and Recoilize.