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

serverreq

v1.1.0

Published

Production-ready DevTools for intercepting HTTP/HTTPS requests in Node.js applications with React DevTools UI

Readme

ServerReq

Production-ready DevTools for intercepting and visualizing HTTP/HTTPS requests in Node.js applications.

ServerReq DevTools

Features

  • 🔍 HTTP/HTTPS Interception - Captures all fetch, http.request, and https.request calls
  • Real-time DevTools - Beautiful floating panel similar to React Query DevTools
  • 🔒 Secret Masking - Automatically masks sensitive headers and body fields
  • 🎯 Next.js Integration - First-class support for Next.js App Router
  • 🚀 Zero Config CLI - Just prefix your command with serverreq
  • 🔌 Socket.IO Transport - Reliable real-time communication

Installation

npm install --save-dev serverreq

Usage

Option 1: Next.js App Router (Recommended)

Step 1: Enable the instrumentation hook in next.config.ts:

// next.config.ts
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  experimental: {
    instrumentationHook: true,
  },
};

export default nextConfig;

Step 2: Create an instrumentation file:

// instrumentation.ts (in your project root)
export async function register() {
  if (process.env.NODE_ENV === "development") {
    const { setupDevTools } = await import("serverreq/nextjs");
    await setupDevTools();
  }
}

Step 3: Create the SSE API route for DevTools communication:

// app/api/devtools/stream/route.ts
import { createSSEHandler } from "serverreq/nextjs";

export const GET = createSSEHandler();

Step 4: Add the DevTools component to your layout:

// app/layout.tsx
import { ServerReqDevtools } from "serverreq/devtools";

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        {children}
        {process.env.NODE_ENV === "development" && <ServerReqDevtools />}
      </body>
    </html>
  );
}

That's it! The DevTools panel will appear as a floating button in the bottom-right corner.

Option 2: CLI Usage

For any Node.js application, use the CLI:

# Run any Node.js command with request interception
npx serverreq -- node server.js

# Next.js development
npx serverreq -- next dev

# With options
npx serverreq --format=json --exclude="localhost:3000" -- npm start

Option 3: Programmatic Usage

import { install, configure } from "serverreq";

// Configure options
configure({
  enabled: true,
  maskSecrets: true,
  excludeUrls: [/localhost:3000/],
});

// Install interceptors
install();

DevTools Component Props

<ServerReqDevtools
  socketUrl="http://localhost:4000" // Custom socket URL (auto-detected by default)
  defaultOpen={false} // Start with panel open
  position="bottom-right" // or "bottom-left"
/>

How It Works

Architecture

┌─────────────────────────────────────────────────────────────┐
│                        Next.js Server                        │
│  ┌──────────────────────────────────────────────────────┐   │
│  │  HTTP Interceptor (fetch, http, https)                │   │
│  │            │                                          │   │
│  │            ▼                                          │   │
│  │     Event Bus (in-memory)                             │   │
│  │            │                                          │   │
│  │            ▼                                          │   │
│  │  Socket.IO Server (port 4000)  ◄────────────────────┐│   │
│  └──────────────────────────────────│───────────────────┘   │
└──────────────────────────────────────│──────────────────────┘
                                       │
                ┌──────────────────────┘
                │ WebSocket
                ▼
┌─────────────────────────────────────────────────────────────┐
│                         Browser                              │
│  ┌──────────────────────────────────────────────────────┐   │
│  │  Socket.IO Client                                     │   │
│  │       │                                               │   │
│  │       ▼                                               │   │
│  │  DevToolsStore (useSyncExternalStore)                 │   │
│  │       │                                               │   │
│  │       ▼                                               │   │
│  │  ServerReqDevtools (React Component)                  │   │
│  └──────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘

Key Design Decisions

  1. Standalone Socket.IO Server - Runs on port 4000 to avoid conflicts with Next.js Turbopack
  2. useSyncExternalStore - React 18 pattern for external state management
  3. Singleton Store - Survives HMR and component remounts
  4. Event Bus - Decouples interceptor from transport layer
  5. Production Safety - Automatically disabled when NODE_ENV=production

CLI Options

| Option | Description | | ------------------------- | --------------------------------------- | | --format=<json\|pretty> | Output format (default: pretty for TTY) | | --no-mask | Disable secret masking | | --exclude=<pattern> | URL pattern to exclude (regex) | | --help, -h | Show help |

Configuration

interface ServerReqConfig {
  enabled: boolean; // Enable/disable (default: true in dev)
  format: "json" | "pretty"; // Output format
  maskSecrets: boolean; // Mask sensitive data (default: true)
  secretPatterns: RegExp[]; // Patterns to mask in body
  excludeUrls: RegExp[]; // URL patterns to exclude
  maxBodyLength: number; // Max body preview length (default: 1024)
}

License

MIT