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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nextjs-perfkit

v1.0.11

Published

Frontend performance analyzer for Next.js apps – render time tracking, memory logging, network analysis, DevTools UI.

Readme

🚀 nextjs-perfkit

Frontend performance analytics and DevTools UI for Next.js + React apps. Track render times, memory usage, network performance, prop changes, and export logs for team insights — all from a floating overlay.


npm downloads license


📦 Package Exports

  • CommonJS: dist/cjs/index.js (for Node.js, older bundlers)
  • ESModule: dist/esm/index.js (for modern bundlers like Webpack, Vite, Next.js)

These are automatically selected based on your environment. You can also import directly if needed:

// ESM
import { initPerfKit } from "nextjs-perfkit/dist/esm/index.js";
// CommonJS
const { initPerfKit } = require("nextjs-perfkit/dist/cjs/index.js");

📦 Installation

npm install nextjs-perfkit

🎨 CSS Styling

You must import the overlay CSS manually in your Next.js _app.tsx file:

import "nextjs-perfkit/styles/overlay.css";

export default function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />;
}

⚠️ If you forget to include this, the overlay will inject fallback inline styles with a warning.


🚀 Quick Start

import { initPerfKit } from "nextjs-perfkit";

if (process.env.NODE_ENV === "development") {
  initPerfKit(); // initializes DevTools floating panel
}

🧪 Example Usage

"use client";
import { useEffect } from "react";
import {
  useRenderHeatmap,
  useMemoryTracker,
  usePropDebugger,
  registerAlertHandler,
  checkMemoryUsage,
  trackNetworkRequest,
  downloadLogs,
} from "nextjs-perfkit";

export default function Home() {
  useRenderHeatmap("HomePage");
  useMemoryTracker(3000);
  usePropDebugger({ propA: "value" });

  useEffect(() => {
    registerAlertHandler((msg, type, meta) => {
      console.warn(`[ALERT - ${type}]`, msg, meta);
    });

    setInterval(() => {
      checkMemoryUsage();
    }, 5000);

    trackNetworkRequest("/api/example");
  }, []);

  return (
    <main data-perf-label="HomePage">
      <h1>🚀 Hello PerfKit</h1>
      <button onClick={downloadLogs}>📥 Download Logs</button>
    </main>
  );
}

📚 Utility Highlights

useMemoryTracker(intervalMs?: number)

Tracks memory usage via performance.memory and logs it regularly. 🚨 Triggers an alert if heap usage exceeds a defined threshold (default: 100MB).

useRenderHeatmap(label: string)

Measures render duration of a component and outlines it with a visual border if slow. 📏 Useful for identifying visual bottlenecks.

usePropDebugger(props)

Logs changed props that cause a re-render. 🔍 Helps debug unnecessary re-renders in components.

registerAlertHandler(callback)

Registers a custom global alert handler. 💡 Use this to display toast messages or logs when memory/network thresholds are crossed.

trackNetworkRequest(url: string)

Monitors fetch calls and tracks repeated calls to the same endpoint within a short window (10s by default). 📡 Prevents performance issues caused by over-fetching.

downloadLogs()

Exports all collected logs (render, memory, network, etc.) as a downloadable .json file. 📝 Perfect for team debugging or offline analysis.


🕵️‍♂️ How to use usePropDebugger

The usePropDebugger hook helps you track which props are changing and causing your component to re-render. This is useful for debugging unnecessary renders and optimizing your React components.

Example

"use client";
import { usePropDebugger } from "nextjs-perfkit";

export default function MyComponent(props) {
  usePropDebugger(props);

  return (
    <div>
      <h2>Check the console for prop changes!</h2>
    </div>
  );
}
  • Just call usePropDebugger(props) at the top of your component.
  • On every render, it will log which props have changed since the last render.

📑 Types

You can import type-safe log definitions like so:

import type { PerfLogEntry } from "nextjs-perfkit/types";

📤 Exportable Logs

PerfKit collects structured logs from memory, network, and render events. You can export them using:

import { downloadLogs } from "nextjs-perfkit";

downloadLogs(); // Triggers a JSON download

🛠 Project Structure

src/
├── hooks/              # useRenderHeatmap, useMemoryTracker, usePropDebugger
├── utils/              # trackMemory, network, alerts, logging
├── types.ts            # exported types
├── DevToolsOverlay.tsx # floating overlay component
├── index.ts            # main entry exports
styles/
├── overlay.css         # external UI styles

🛠 Future Roadmap

📢 Alerts & Thresholds

  • Memory usage > 100MB → ⚠️ alert in UI
  • Fetch calls → ⏱️ duration log in console
  • Render time > 16ms → 🔴 red outline

👥 Contributing

  1. Fork the repo
  2. Clone locally: git clone https://github.com/deepbratt/nextjs-perfkit.git
  3. Install deps: npm install
  4. Test with a Next.js sample project

📝 License

MIT © 2025 Deep Bratt


Made with ❤️ for frontend performance engineering.