React DevTools Core

7.0.1 · active · verified Sun Apr 19

react-devtools-core is a foundational package offering low-level APIs to enable integration of the React DevTools UI with custom React renderers, primarily those operating outside of a browser environment, such as React Native. Unlike the `react-devtools` package, which provides the standalone UI, `react-devtools-core` is intended for renderer authors who need to expose their host environment to the DevTools frontend. The current stable version is 7.0.1. Its release cadence is closely coupled with React's core library, often receiving updates alongside React's own patch and minor versions, which historically occur frequently to address bug fixes and performance improvements. A key differentiator is its explicit focus on non-browser environments, providing the necessary backend bridge for DevTools functionality where standard browser extensions are not applicable. It ensures that developers building with custom React renderers can still leverage the powerful inspection, profiling, and debugging capabilities of the official React DevTools.

Common errors

Warnings

Install

Imports

Quickstart

This snippet demonstrates how to initialize and connect a custom React renderer's backend to the React DevTools UI, ensuring the connection is established before React itself is imported and only in development environments.

if (process.env.NODE_ENV !== 'production') {
  // It is crucial that connectToDevTools is called BEFORE React or React Native are imported.
  // This ensures the DevTools backend can properly instrument React's internals.
  const { initialize, connectToDevTools } = require("react-devtools-core");

  // Optional: Define custom settings for DevTools behavior.
  const devToolsSettings = {
    appendComponentStack: true,
    breakOnConsoleErrors: false,
    showInlineWarningsAndErrors: true,
    hideConsoleLogsInStrictMode: false
  };

  initialize(devToolsSettings);
  
  // Establish connection to the DevTools frontend.
  // Host and port can be configured if the frontend is not on localhost:8097.
  connectToDevTools({
    host: process.env.REACT_DEVTOOLS_HOST ?? 'localhost',
    port: parseInt(process.env.REACT_DEVTOOLS_PORT ?? '8097', 10),
    isAppActive: () => true // Replace with actual app active check if needed
  });

  console.log('React DevTools core backend initialized.');
}
// Proceed with importing React, React Native, or your custom renderer AFTER this setup.

view raw JSON →