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

react-tree-lens

v1.1.2

Published

A React component tree visualization lens with beautiful UI for debugging and development

Readme

React Tree Lens 🔍

A powerful React component for visualizing your component hierarchy in real-time. Perfect for debugging, learning React architecture, and understanding component relationships.

✨ What's New (Improved Version)

  • 📊 Rich Component Tree: Shows actual component hierarchy with proper nesting
  • 🎯 Interactive Interface: Click to expand/collapse nodes and inspect props
  • 🔍 Props Inspection: View component props and their values in detail
  • 📱 Responsive Design: Beautiful, modern UI that works on all screen sizes
  • ⚡ Zero Configuration: Just wrap your app and start exploring
  • 🎨 Visual Icons: Different icons for components, HTML elements, and text nodes

🚀 Quick Start

Installation

npm install react-tree-lens

TypeScript Support

This package includes full TypeScript support with exported type definitions.

Basic Usage

import React from 'react';
import { ReactTreeProvider, TreeViewer, useReactTree } from 'react-tree-lens';
import type { ReactTreeProviderProps, TreeNode, TreeContext } from 'react-tree-lens';

// Basic setup
function App() {
  return (
    <ReactTreeProvider showTreeViewer={true} position="right" theme="dark">
      <YourAppContent />
    </ReactTreeProvider>
  );
}

// Using the hook with proper typing
function MyComponent() {
  const treeContext: TreeContext = useReactTree();
  
  return (
    <div>
      <button onClick={treeContext.toggleVisibility}>
        Toggle Tree View
      </button>
    </div>
  );
}

Type Definitions

import type {
  TreeNode,           // Tree structure interface
  ReactTreeProviderProps, // Provider props
  TreeContext,        // Context interface
  TreePosition,       // 'left' | 'right' | 'top' | 'bottom'
  TreeTheme,          // 'light' | 'dark'
  TreeNodeType,       // 'component' | 'html' | 'text'
  TreeViewerProps,    // TreeViewer component props
  UseReactTreeReturn  // Hook return type
} from 'react-tree-lens';

Advanced Usage

import React from 'react';
import { ReactTreeProvider, TreeViewer } from 'react-tree-lens';
import type { ReactTreeProviderProps, TreePosition, TreeTheme } from 'react-tree-lens';

interface CustomAppProps {
  children: React.ReactNode;
  debugMode?: boolean;
}

function CustomApp({ children, debugMode = false }: CustomAppProps) {
  const position: TreePosition = 'right';
  const theme: TreeTheme = 'dark';
  
  const providerProps: ReactTreeProviderProps = {
    children,
    showTreeViewer: debugMode,
    position,
    theme
  };

  return (
    <ReactTreeProvider {...providerProps}>
      {children}
    </ReactTreeProvider>
  );
}

📖 Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | children | ReactNode | - | Your React application components | | showTreeViewer | boolean | true | Whether to show the tree viewer initially | | position | 'left' \| 'right' \| 'top' \| 'bottom' | 'left' | Position of the tree viewer | | theme | 'light' \| 'dark' | 'light' | Color theme (coming soon) |

🎯 Features

Real-time Component Analysis

  • Live Updates: Tree structure updates as your components change
  • Component Types: Distinguishes between React components, HTML elements, and text nodes
  • Hierarchy Visualization: Clear parent-child relationships with proper indentation

Interactive Tree Viewer

  • Expandable Nodes: Click arrows to expand/collapse component branches
  • Node Selection: Click on any component to see its details
  • Props Inspector: View all props passed to selected components
  • Component Count: Shows total number of components in your tree

Modern UI

  • Clean Design: Minimal, developer-friendly interface
  • Color Coding: Components, HTML elements, and text have different colors
  • Responsive Layout: Adapts to different screen sizes and positions
  • Floating Toggle: Easy-to-access eye button to show/hide the tree

🔧 How It Works

The React Tree Lens analyzes the component structure by:

  1. Wrapping Your App: Provides context to all child components
  2. Parsing Elements: Recursively analyzes React elements and their children
  3. Building Tree Structure: Creates a hierarchical representation of your components
  4. Real-time Updates: Rebuilds the tree when components change

🎨 Visual Legend

  • 🔵 Component: Custom React components
  • 🟢 HTML Element: Native HTML tags (div, span, button, etc.)
  • Text Node: String and number content

📱 Demo

Visit our live demo to see the tree viewer in action with different component patterns:

  • Basic Components: Simple component hierarchy
  • Form Components: Complex forms with validation
  • Deeply Nested: Multi-level component nesting
  • Dynamic Content: Components with conditional rendering

🛠️ Development

To run this project locally:

# Clone the repository
git clone <your-repo-url>
cd react-tree-lens

# Install dependencies
npm install

# Start development server
npm run dev

# Open http://localhost:4000

📝 Important Notes

Current Limitations

  • Component Boundaries: The tree viewer can only show components that are direct children of ReactTreeProvider
  • Internal State: Cannot inspect component state or hooks (only props)
  • Performance: Large component trees may impact performance

Best Practices

  • Use in development mode for debugging and learning
  • Position the tree viewer where it doesn't interfere with your app
  • Consider the tree viewer size when positioning on smaller screens

🔮 Roadmap

  • [ ] State Inspection: View component state and hooks
  • [ ] Performance Metrics: Show render times and optimization opportunities
  • [ ] Component Search: Filter and search through component tree
  • [ ] Export Tree: Save component hierarchy as JSON or image
  • [ ] Dark Theme: Full dark mode support
  • [ ] React DevTools Integration: Connect with React DevTools

🤝 Contributing

We welcome contributions! Please feel free to submit issues and pull requests.

📄 License

MIT License - see LICENSE file for details.


Made with ❤️ for the React community

Perfect for developers who want to understand and visualize their React component architecture.