Reactotron logo

Reactotron

A powerful desktop inspector for visualizing application state, network requests, and logs in React and React Native.

npm install reactotron
15.4K288/weekv0.9.00BMIT151 issues
Last updated: 2016-08-09
Star history chart for skellock/reactotron

TL;DR

A cross-platform desktop application designed to control, monitor, and inspect your React or React Native application in real-time.

Ideally suited for React Native development where browser tools are limited, serving as a comprehensive command center for debugging state and side effects.

Why Reactotron?

Reactotron solves the visibility problem in React development, particularly in React Native where standard browser tools are often inaccessible or cumbersome to connect. Instead of relying on scattered console.log statements or heavy platform-specific debuggers, Reactotron provides a unified "Timeline" of your application's life.

  • Unified Event Timeline: View a chronological stream of Redux/state actions, network requests, log messages, and errors in one clean interface.
  • State Snapshots & Restore: Inspect your global state (Redux, MobX, Zustand, MST) at any point in time, modify it on the fly, or restore previous snapshots to replay bugs.
  • Network Inspection: Monitor API requests and responses internally without needing external proxy tools like Charles or Wireshark.
  • Custom Commands: Define custom commands in your code that can be triggered from the Reactotron UI, effectively creating a remote control for your app (e.g., "Reset Navigation", "Fill Form").
  • Image Overlay: Overlay a design image on top of your React Native app to verify pixel-perfect implementation directly on the simulator or device.

Code Snippet

To use Reactotron, you typically initialize it in a dedicated configuration file, ensuring it only runs in development environments.

// ReactotronConfig.js
import Reactotron from 'reactotron-react-js'; // or 'reactotron-react-native'

// Only run this in development
if (process.env.NODE_ENV === 'development') {
  Reactotron
    .configure({ name: 'My Awesome App' }) // Controls connection settings
    .useAllWindows() // Inspects network activity
    .connect(); // Lets go!
    
  // Optional: Extend console.log to pipe to Reactotron
  console.tron = Reactotron;
}

export default Reactotron;

Once configured, you can use console.tron.log() to send rich objects to the desktop app, or hook it into your state management middleware to see actions flow automatically.

Pros and Cons

No library is perfect; understanding the trade-offs is key to selecting the right tool.

Pros

  • React Native Superiority: Offers a significantly better debugging experience for RN than the default remote debugger or Flipper for JS-centric tasks.
  • Visual Log Stream: Organizes logs, network calls, and state changes in a readable, filterable feed rather than a messy console output.
  • Ecosystem Integrations: First-class plugins available for Redux, Redux-Saga, MobX-State-Tree, and standard React hooks.

Cons

  • Setup Boilerplate: Requires explicit configuration files and conditional imports to ensure debugging code doesn't leak into production bundles.
  • Context Switching: It is a separate desktop window, requiring you to alt-tab away from your browser or simulator, unlike integrated browser DevTools.
  • Web Redundancy: For pure React web apps, standard Chrome/Firefox DevTools often provide sufficient network and console capabilities without extra setup.

Comparison with Other Debugging Tools

The table below outlines the positioning differences between Reactotron and other popular debugging utilities:

LibraryDesign PhilosophyBest ForPain Points
ReactotronDesktop Companion
A dedicated "Mission Control" app for inspecting app internals via a WebSocket connection.
React Native
The de-facto standard for visualizing state and network in RN apps where browser tools fail.
Setup Friction
Requires installing a desktop app and adding configuration code to your project.
Redux DevToolsBrowser Extension
Focuses strictly on state time-travel and action inspection within the browser context.
Web Redux Apps
Perfect for pure Redux state debugging without needing general logging features.
Limited Scope
Doesn't handle network requests or general logs; tied primarily to Redux-like patterns.
FlipperNative Platform
Meta's heavy-duty debugging platform integrating native iOS/Android layers with JS.
Deep Native Debugging
When you need to inspect Native Layouts or native database tables alongside JS.
Heaviness
Can be resource-intensive, notoriously difficult to set up, and often unstable.

Ecosystem & Extensions

Reactotron is highly extensible through a plugin system.

  • reactotron-redux: Tracks Redux actions and state changes, allowing for state replay and snapshotting.
  • reactotron-apisauce: Automatically logs network requests/responses made with the Apisauce library.
  • reactotron-mst: Deep integration for MobX-State-Tree, offering live state tree navigation and patch tracking.