Bippy: React Internals Hacking Toolkit

0.5.39 · active · verified Sun Apr 19

Bippy is a specialized JavaScript library designed to provide direct access to React's internal Fiber tree and other non-public APIs, primarily for advanced instrumentation, debugging, and experimental tooling. It operates by emulating React DevTools' hook (`window.__REACT_DEVTOOLS_GLOBAL_HOOK__`) before React itself initializes, thus bypassing standard access restrictions. The current stable version is 0.5.39. While there isn't a fixed release cadence, updates typically occur reactively to maintain compatibility with new React major or minor versions (currently supporting v17-19) as internal structures change. Its key differentiator is providing simplified utility functions to traverse the Fiber tree and extract properties like `memoizedProps`, `memoizedState`, and `dependencies` across different React versions, reducing the need for deep React source code knowledge. It's explicitly not recommended for production applications due to its reliance on unstable internal APIs.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to initialize Bippy's instrumentation BEFORE React loads, hooking into the `onCommitFiberRoot` event to traverse and log details about every Fiber in the React tree upon each commit cycle.

import { instrument, onCommitFiberRoot, traverseFiber } from 'bippy'; // Must be imported BEFORE React

// This block MUST execute before any React import or ReactDOM.createRoot call.
// For a typical SPA, place this at the very top of your main entry file (e.g., index.ts/js).

instrument({
  onCommitFiberRoot: (root) => {
    console.log('React commit detected for root:', root.current); // root.current is the actual Fiber root
    traverseFiber(root.current, (fiber) => {
      // This callback runs for every fiber in the current React tree upon commit.
      // 'fiber' contains properties like type, memoizedProps, memoizedState, etc.
      if (fiber.elementType && typeof fiber.elementType === 'function') {
        // Log component names (functional or class components)
        console.log(`Component Fiber: ${fiber.elementType.displayName || fiber.elementType.name || 'AnonymousComponent'}`);
      } else if (fiber.stateNode instanceof HTMLElement) {
        // Log host (DOM) element tags
        console.log(`Host Fiber (DOM): <${fiber.stateNode.tagName.toLowerCase()} />`);
      } else if (fiber.type) {
        // Log other types of fibers (e.g., HostText, Suspense, Provider)
        console.log(`Other Fiber Type: ${typeof fiber.type === 'symbol' ? fiber.type.toString() : fiber.type}`);
      }
    });
  },
  // Additional hooks can be configured here, e.g., onMount, onUnmount
  // onMount: (fiber) => console.log('Fiber Mounted:', fiber),
  // onUnmount: (fiber) => console.log('Fiber Unmounted:', fiber),
});

console.log('Bippy instrumentation activated successfully. Your React app will now be monitored.');

// Your React application's entry point would typically follow here,
// e.g., import ReactDOM from 'react-dom/client'; ReactDOM.createRoot(...).render(...);

view raw JSON →