npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mouaad_idoufkir/why-render

v0.25.21

Published

A comprehensive React 19 developer tool that detects unnecessary re-renders with visual debugging panels, performance monitoring, and AI-powered suggestions.

Readme

@mouaad_idoufkir/why-render

npm version License: MIT TypeScript React 19

A comprehensive, lightweight developer tool for React 19 that detects unnecessary re-renders, visualizes performance with a Flame Graph, and helps you optimize your application.

🚀 Why use this?

React is fast, but unnecessary re-renders can slow down your app. Identifying why a component re-rendered (was it a prop change? a state update? a parent render?) can be difficult.

@mouaad_idoufkir/why-render solves this by:

  1. Tracking every render and its cause.
  2. Diffing props to show exactly what changed (value vs. reference).
  3. Visualizing performance with an interactive Flame Graph and Timeline.
  4. Zero Overhead in production (fully tree-shakeable).

📦 Installation

npm install @mouaad_idoufkir/why-render
# or
yarn add @mouaad_idoufkir/why-render
# or
pnpm add @mouaad_idoufkir/why-render

🏁 Quick Start

1. Add the DevTools (Optional but Recommended)

Add the <WhyRenderDevTools /> component to the root of your application (e.g., in App.tsx or main.tsx).

import React from 'react';
import { WhyRenderDevTools } from '@mouaad_idoufkir/why-render/ui';

const App = () => {
  return (
    <>
      <MyComponent />
      {/* Only renders in development */}
      <WhyRenderDevTools />
    </>
  );
};

2. Track a Component

Use the useWhyRender hook inside any component you want to debug.

import { useWhyRender } from '@mouaad_idoufkir/why-render';

const UserProfile = (props) => {
  // 1. Pass props
  // 2. Pass a unique name for the component
  useWhyRender(props, 'UserProfile');

  return <div>{props.name}</div>;
};

Open your browser console or the WhyRender DevTools panel to see the logs!


🛠 Features & Usage

Hooks & HOCs

useWhyRender(props, componentName, options?)

The primary hook for functional components.

useWhyRender(props, 'MyComponent', {
  verbose: true, // Log full diffs to console
  compareStrategy: 'deep' // 'shallow' | 'deep' | 'fast-deep'
});

withWhyRender(Component, options?)

A Higher-Order Component (HOC) for class components or when you prefer wrapping exports.

import { withWhyRender } from '@mouaad_idoufkir/why-render';

const MyComponent = (props) => <div>...</div>;

export default withWhyRender(MyComponent, { verbose: true });

DevTools UI

The library comes with a powerful DevTools UI that overlays your application.

  • Toggle: Click the floating "WR" badge or press Ctrl+Shift+X.
  • Flame Graph: Visualize which components are taking the most time to render.
  • Component Tree: See the hierarchy of tracked components.
  • Timeline: View a chronological history of all render events.
  • Diff Viewer: Inspect exactly which props changed between renders.

Diffing Strategies

You can configure how the library compares props to detect changes:

  1. shallow (Default): Uses Object.is. Fast and standard for React.
  2. fast-deep: Recursive comparison with a depth limit (default 3). Good for checking if nested data changed structure.
  3. deep: Full deep equality check. Useful for finding "reference stability" issues (e.g., a new object with the same content is passed every time).
  4. custom: Provide your own comparison function.
useWhyRender(props, 'ComplexData', {
  compareStrategy: 'deep'
});

⚙️ Configuration Options

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | compareStrategy | 'shallow' \| 'deep' \| 'fast-deep' | 'shallow' | How to compare props. | | verbose | boolean | false | If true, logs detailed diffs to the console. | | skipKeys | string[] | [] | List of prop names to ignore during comparison. | | trackHooks | boolean | true | (Experimental) Attempt to track hook changes. |


🚀 Production Optimization

This library is designed to be Zero Overhead in production.

  1. Tree Shaking: The package.json is marked with "sideEffects": false.
  2. Dev-Only Guards: All logic is wrapped in process.env.NODE_ENV !== 'production' checks.
  3. Empty Exports: In production builds, hooks and HOCs are replaced with no-ops.

Ensure your bundler (Vite, Webpack, etc.) is configured to handle process.env.NODE_ENV.


🤝 Contributing

Contributions are welcome! Please read our Architecture Guide to understand the internals.

  1. Fork the repo.
  2. Install dependencies: npm install
  3. Run tests: npm test
  4. Submit a PR.

📄 License

MIT © Mouaad Idoufkir