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

@cgaspard/webappmcp-react

v0.1.6

Published

React plugin for WebApp MCP - adds React Router tools and React-specific functionality

Readme

@cgaspard/webappmcp-react

React plugin for WebApp MCP that provides React Router and Next.js navigation tools.

Installation

npm install @cgaspard/webappmcp @cgaspard/webappmcp-react

Usage

Add the React plugin to your WebApp MCP configuration:

const { webappMCP } = require('@cgaspard/webappmcp');
const reactPlugin = require('@cgaspard/webappmcp-react').default;

app.use(webappMCP({
  wsPort: 4835,
  transport: 'sse',
  plugins: [reactPlugin]
}));

Available Tools

react_get_current_route

Get the current route information from React Router or Next.js.

// React Router v6 response
{
  type: 'react-router-v6',
  pathname: '/products/123',
  search: '?category=electronics',
  hash: '#reviews',
  state: null,
  key: 'default'
}

// Next.js response
{
  type: 'nextjs',
  pathname: '/products/[id]',
  query: { id: '123', category: 'electronics' },
  asPath: '/products/123?category=electronics',
  route: '/products/[id]',
  locale: 'en'
}

react_navigate

Navigate to a different route using React Router or Next.js.

// Simple navigation
{
  path: '/products'
}

// With query parameters
{
  path: '/search',
  query: { q: 'laptop', category: 'electronics' }
}

// Replace history entry
{
  path: '/login',
  replace: true
}

react_get_component_tree

Get information about the React component tree.

// Returns component tree info
{
  type: 'react-devtools',
  message: 'React DevTools detected',
  rendererCount: 1,
  info: 'Full component tree inspection requires React DevTools browser extension'
}

react_get_state

Get state from exposed React components.

// Returns component state and props
{
  name: 'UserProfile',
  state: { isLoading: false, user: {...} },
  props: { userId: '123' },
  hooks: {}
}

React Router v6 Integration

For React Router v6 apps, use the provided hook to enable full routing support:

import { useNavigate, useLocation } from 'react-router-dom';
import { useEffect } from 'react';

function App() {
  const navigate = useNavigate();
  const location = useLocation();
  
  // Enable WebApp MCP routing support
  useEffect(() => {
    if (window.useWebAppMCPRouter) {
      window.useWebAppMCPRouter(navigate, location);
    }
  }, [navigate, location]);
  
  return <YourApp />;
}

Exposing Components

To allow MCP tools to inspect component state:

import { useEffect } from 'react';

function UserProfile({ userId }) {
  const [user, setUser] = useState(null);
  const [isLoading, setIsLoading] = useState(true);
  
  // Expose component to WebApp MCP
  useEffect(() => {
    if (window.registerReactComponent) {
      window.registerReactComponent('UserProfile', {
        state: { user, isLoading },
        props: { userId }
      });
    }
  }, [user, isLoading, userId]);
  
  return <div>...</div>;
}

Features

  • Multi-router support: Works with React Router (v5, v6) and Next.js
  • Route monitoring: Automatically tracks navigation events
  • Component inspection: Expose component state for debugging
  • TypeScript support: Fully typed for better development experience
  • No configuration needed: Detects router type automatically

Client-Side Extensions

The plugin automatically:

  • Detects and monitors React Router and Next.js navigation
  • Provides hooks for React Router v6 integration
  • Logs route changes to DevTools
  • Enables component state inspection

Compatibility

  • React Router v5.x and v6.x
  • Next.js 10.x and above
  • React 16.8+ (with hooks)
  • Works with Create React App

Advanced Usage

Custom Route Monitoring

// In your React app
window.addEventListener('load', () => {
  if (window.WebAppMCPClient) {
    // Custom route tracking logic
    history.listen((location) => {
      window.WebAppMCPClient.devTools?.logMCPEvent('Custom route', {
        path: location.pathname,
        customData: getCustomRouteData()
      });
    });
  }
});

License

MIT