Skip to content

aidenybai/react-scan

Repository files navigation

React Scan

React Scan automatically detects performance issues in your React app.

Previously, tools like:

React Scan attempts to solve these problems:

  • It requires no code changes – just drop it in
  • It highlights exactly the components you need to optimize
  • No more having to use flame graphs when profiling
  • Always accessible through a toolbar on page

Try it in 5 seconds

npx react-scan airbnb.com

or on your local website

npx react-scan localhost:3000

all installation options below

Trusted by engineering teams at:

Airbnb                  

React Scan in action

Install

Package managers

npm i react-scan
pnpm add react-scan
bun add react-scan
yarn add react-scan

Usage

CLI

If you want to run react scan on any URL (including localhost) from the cli, you can run:

npx react-scan@latest http://localhost:3000
# you can technically scan ANY website on the web:
# npx react-scan@latest https://react.dev

You can add it to your existing dev process as well. Here's an example for Next.js:

{
  "scripts": {
    "dev": "next dev",
    "scan": "next dev & npx react-scan@latest localhost:3000"
  }
}

Browser Extension

If you want to install the extension, follow the guide here.

React Native

See discussion

After Setup

How to use/feature descriptions

Toolbar

All react scan features are exposed through the toolbar that you will see in the bottom right corner of your page:

image

You can drag this toolbar to any corner of the page

Render Outlines

By default, react scan will show outlines over components when they render.

interact with your page to try it out!

If you want to turn the outlines off, you can use the toggle in the toolbar to turn them off. This will persist across page loads and will only re-enable when you toggle it back on:

Pasted image 20250629130910

Why did my component render

If you want to find out why a component re-rendered, you can click the icon at the very left of the toolbar, and then click on the component you want to inspect Pasted image 20250629131113 Anytime the component renders, React Scan will tell you what props, state, or context changed during the last render. If those values didn't change, and your component was wrapped in React.memo, it would not of rendered.

To the right of the of the "Why did this component render" view, you will see the component tree of your app. When a component re-renders, the count will be updated in the tree. You can click on any item in the tree to see why it rendered.

Profiling slowdowns in your app

Re-render outlines are good for getting a high level overview of what's slowing down your app, and the "Why did this render" inspector is great when you know which component you want to debug. But, what if you don't know which components are causing your app to slowdown?

React Scan's profiler, accessible through the notification bell in the toolbar:

image

is an always on profiler that alerts you when there is an FPS drop or slow interaction (click, type). Every slowdown and interaction has an easy to understand profile associated with it.

Screen-2025-06-29-131708.1.1.mp4

The profile has 3 parts:

Ranked

This ranks how long it took to render your components. Every component instance that came from the same component will have its render time added together- if you render 1000 ListItem's , and they each take 1s to render, we will say ListItem took 1000s to render )

image

If you click on any bar, it will tell you what caused those components to re-render:

Pasted image 20250629132303

This table is telling you that there were 4 instances of this component rendered, and all 4 of them had their close, style, and hide props change. If those didn't change, and the component was React.memo'd, they would not have rendered

If you click the arrow on the side of each bar, it will show you the ancestors of the components that rendered that component, along with how long it took to render that ancestor. This is great for giving context to understand what component you're looking at:

image

If you hover your mouse over a bar, all instances of that component will be outlined in purple over the page:

image

Overview

The overview gives you a high level summary of what time was spent on during the slowdown or interaction.

This breaks down if the time spent was on renders, react hooks (or other javascript not from react), or the browser spending time to update the dom and draw the next frame

This is great to find out if React was really the problem, or if you should be optimizing other things, like CSS: Pasted image 20250629132429

Prompts

The prompts section gives you 3 different kind of prompts that you can pass to an LLM based on what your goal is. These prompts automatically includes data about the profile:

Pasted image 20250629132608

Misc

If you want to hear a sound every time a slowdown is collected, you can turn on audio alerts in this section

Hiding the toolbar

The React Scan toolbar can be distracting when you're not using it. To hide the toolbar, you can drag/throw it into the side of the page.

Screen-2025-06-29-141048.mp4

The toolbar will stay collapsed into the side of the page until you drag it back out. This will persist across page load

API Reference

Options
export interface Options {
  /**
   * Enable/disable scanning
   *
   * Please use the recommended way:
   * enabled: process.env.NODE_ENV === 'development',
   *
   * @default true
   */
  enabled?: boolean;

  /**
   * Force React Scan to run in production (not recommended)
   *
   * @default false
   */
  dangerouslyForceRunInProduction?: boolean;
  /**
   * Log renders to the console
   *
   * WARNING: This can add significant overhead when the app re-renders frequently
   *
   * @default false
   */
  log?: boolean;

  /**
   * Show toolbar bar
   *
   * If you set this to true, and set {@link enabled} to false, the toolbar will still show, but scanning will be disabled.
   *
   * @default true
   */
  showToolbar?: boolean;

  /**
   * Animation speed
   *
   * @default "fast"
   */
  animationSpeed?: "slow" | "fast" | "off";

  /**
   * Track unnecessary renders, and mark their outlines gray when detected
   *
   * An unnecessary render is defined as the component re-rendering with no change to the component's
   * corresponding dom subtree
   *
   *  @default false
   *  @warning tracking unnecessary renders can add meaningful overhead to react-scan
   */
  trackUnnecessaryRenders?: boolean;

  onCommitStart?: () => void;
  onRender?: (fiber: Fiber, renders: Array<Render>) => void;
  onCommitFinish?: () => void;
  onPaintStart?: (outlines: Array<Outline>) => void;
  onPaintFinish?: (outlines: Array<Outline>) => void;
}
  • scan(options: Options): Imperative API to start scanning
  • useScan(options: Options): Hook API to start scanning
  • setOptions(options: Options): void: Set options at runtime
  • getOptions(): Get the current options
  • onRender(Component, onRender: (fiber: Fiber, render: Render) => void): Hook into a specific component's renders

Why React Scan?

React can be tricky to optimize.

The issue is that component props are compared by reference, not value. This is intentional – this way rendering can be cheap to run.

However, this makes it easy to accidentally cause unnecessary renders, making the app slow. Even in production apps, with hundreds of engineers, can't fully optimize their apps (see GitHub, Twitter, and Instagram).

This often comes down to props that update in reference, like callbacks or object values. For example, the onClick function and style object are re-created on every render, causing ExpensiveComponent to re-render and slow down the app, even if ExpensiveComponent was wrapped in React.memo:

<ExpensiveComponent onClick={() => alert("hi")} style={{ color: "purple" }} />

React Scan helps you identify these issues by automatically detecting and highlighting renders that cause performance issues. Now, instead of guessing, you can see exactly which components you need to fix.

Want monitor issues in production? Check out React Scan Monitoring!

Resources & Contributing Back

Want to try it out? Check the our demo.

Looking to contribute back? Check the Contributing Guide out.

Want to talk to the community? Hop in our Discord and share your ideas and what you've build with React Scan.

Find a bug? Head over to our issue tracker and we'll do our best to help. We love pull requests, too!

We expect all contributors to abide by the terms of our Code of Conduct.

→ Start contributing on GitHub

Acknowledgments

React Scan takes inspiration from the following projects:

License

React Scan is MIT-licensed open-source software by Aiden Bai, Million Software, Inc., and contributors.