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

@prograpedia/next-server-timing

v0.1.3

Published

A lightweight library for Next.js applications that adds Server-Timing headers to HTTP responses. Enables performance monitoring of server operations with precise timing metrics, helping developers identify bottlenecks and optimize application performance

Readme

npm version npm downloads GitHub stars

Next Server Timing

A lightweight library for Next.js applications that adds Server-Timing headers to HTTP responses. Enables performance monitoring of server operations with precise timing metrics, helping developers identify bottlenecks and optimize application performance.

What is Server-Timing?

The Server-Timing HTTP header allows web servers to communicate performance metrics about request-handling operations to the client. This enables developers to:

  • Monitor server-side operations with high precision
  • Track performance of server components, database queries, and other operations
  • Visualize server timing metrics in browser developer tools
  • Identify bottlenecks in your application's server-side processing

Installation

# npm
npm install @prograpedia/next-server-timing

# yarn
yarn add @prograpedia/next-server-timing

# pnpm
pnpm add @prograpedia/next-server-timing

Usage

Configure with Next.js

Wrap your Next.js configuration with the withServerTiming function:

import { withServerTiming } from '@prograpedia/next-server-timing';
import { NextConfig } from 'next';

const nextConfig: NextConfig = {
  // your next config
};
export default withServerTiming(nextConfig);

Create a Custom Server

If you're using a custom server setup, incorporate the library using the requestHandlerWithServerTiming function:

import next from "next";
import { createServer } from "node:http";
import { parse } from "node:url";

const app = next();

app.prepare().then(() => {
  const { requestHandlerWithServerTiming } = require("@prograpedia/next-server-timing");
  const handle = requestHandlerWithServerTiming(app.getRequestHandler());
  createServer((req, res) => {
    const parsedUrl = parse(req.url || "", true);
    handle(req, res, parsedUrl);
  }).listen(3000, (err) => {
    if (err) throw err;
    console.log("> Ready on http://localhost:3000");
  });
});

Instrument Server Actions

Add performance metrics to your server-side operations with the timing function:

"use server";
import { timing } from "@prograpedia/next-server-timing";

export async function action() {
  const metrics = timing();
  const time = performance.now();
  try {
    return await new Promise((resolve) => setTimeout(resolve, 1000));
  } finally {
    metrics["action"] = {dur: performance.now() - time, desc: "action"};
  }
}

How It Works

The library creates and manages Server-Timing headers for your Next.js application:

  1. It intercepts HTTP responses from your Next.js application
  2. Collects timing metrics from your instrumented code using AsyncLocalStorage
  3. Formats these metrics into standards-compliant Server-Timing headers
  4. Appends these headers to the HTTP response before it's sent to the client

These metrics can then be viewed in your browser's developer tools under the Network tab.

Browser Compatibility

Server-Timing headers are supported in most modern browsers:

  • Chrome 65+
  • Firefox 61+
  • Edge 79+
  • Safari 16.4+

License

MIT