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

app-tracking-npm-package

v1.0.8

Published

Track and visualize Next.js components, props, and state for the SPS Canvas tool

Readme

Next.js Component Tracker

A lightweight library that enables tracking React component state, props, and render behavior in Next.js applications for visualization in the SPS Canvas tool.

Installation

npm install --save app-tracking-npm-package
# or
yarn add app-tracking-npm-package

Usage

1. Initialize the tracker in your app

For App Router (Next.js 13+)

Add the tracker to your root layout:

// app/layout.js
'use client';

import { initTracker } from 'app-tracking-npm-package';
import { useEffect } from 'react';

export default function RootLayout({ children }) {
  useEffect(() => {
    if (typeof window !== 'undefined') {
      initTracker();
    }
  }, []);

  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  );
}

For Pages Router

Add the tracker to your _app.js file:

// pages/_app.js
import { initTracker } from 'app-tracking-npm-package';
import { useEffect } from 'react';

function MyApp({ Component, pageProps }) {
  useEffect(() => {
    if (typeof window !== 'undefined') {
      initTracker();
    }
  }, []);

  return <Component {...pageProps} />;
}

export default MyApp;

2. Track components (Optional)

You can enhance your components with tracking capabilities using the withTracking HOC:

import { withTracking } from 'app-tracking-npm-package';

function Button({ onClick, children }) {
  return (
    <button 
      onClick={onClick}
      className="px-4 py-2 bg-blue-600 text-white rounded"
    >
      {children}
    </button>
  );
}

// Export with tracking - second parameter is the component name for the canvas
export default withTracking(Button, 'Button');

3. Track component state

Use the useTrackedState hook to automatically track state changes:

import { useTrackedState } from 'app-tracking-npm-package';

function Counter() {
  // Works just like useState but reports state changes to the Canvas
  const [count, setCount] = useTrackedState(0, 'Counter');
  
  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => setCount(count + 1)}>Increment</button>
    </div>
  );
}

export default Counter;

Connecting to the Canvas

  1. Run your Next.js app locally (e.g., npm run dev)
  2. Open the SPS Canvas tool
  3. Enter your local app URL (typically http://localhost:3000)
  4. Click "Connect"

The Canvas will automatically:

  • Detect your components
  • Visualize the component hierarchy
  • Show real-time props and state changes
  • Track component relationships

API Reference

initTracker()

Initializes the tracker and connects to the Canvas tool when available.

withTracking(Component, displayName)

Higher-Order Component that wraps your React component to track renders and props.

  • Component: The React component to track
  • displayName: (Optional) Name to display in the Canvas (defaults to component name)

useTrackedState(initialState, componentName)

A drop-in replacement for React's useState that tracks state changes.

  • initialState: Initial state value (same as useState)
  • componentName: Name of the component using this state

trackComponent(componentName, props, state)

Low-level function to manually track component data.

  • componentName: Name of the component to track
  • props: Component props object
  • state: Component state object