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

@lmstech/monitor

v0.2.0

Published

Lightweight monitoring package for Next.js apps. Captures server logs, client errors, uncaught exceptions, and unhandled rejections — sends everything to the Observatory dashboard.

Readme

@lmstech/monitor

Lightweight monitoring package for Next.js apps. Captures server logs, client errors, uncaught exceptions, and unhandled rejections — sends everything to the Observatory dashboard.

If MONITOR_URL and MONITOR_KEY aren't set, the entire package is inert. No patching, no listeners, no network calls.

Setup in a consuming app

Four files, nine lines.

1. instrumentation.ts (project root)

export async function register() {
  const { init } = await import("@lmstech/monitor/server");
  init({ app: "my-app", env: "production", version: process.env.COMMIT_SHA });
}

Filtering noisy events

Pass an ignore predicate to drop events before they're reported — useful for noisy-but-harmless errors like HTTP socket aborts from client disconnections:

init({
  app: "my-app",
  env: "production",
  ignore: (event) =>
    event.message === "aborted" && event.stack?.includes("abortIncoming") === true,
});

The predicate runs for every event (console.error, uncaughtException, unhandledRejection, log). Return true to drop. A throwing predicate is treated as "do not ignore" — a broken filter won't hide errors.

2. app/api/monitor/route.ts

export { POST } from "@lmstech/monitor/server";

3. app/layout.tsx

import { Monitor } from "@lmstech/monitor/client";

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        <Monitor app="my-app" env="production">
          {children}
        </Monitor>
      </body>
    </html>
  );
}

4. Environment variables

MONITOR_URL=https://your-dashboard.vercel.app
MONITOR_KEY=your-api-key
COMMIT_SHA=abc123  # typically set by CI (GITHUB_SHA in GitHub Actions)

Don't set these in local dev. The package stays invisible when they're absent.

Custom logging

Server-side

import { log } from "@lmstech/monitor/server";

log({ level: "info", message: "Payment processed", meta: { userId: "123" } });

Client-side

import { useMonitor } from "@lmstech/monitor/client";

const { log } = useMonitor();
log({ level: "error", message: "Checkout failed", meta: { step: "payment" } });

useMonitor() must be called inside the <Monitor> provider tree.

Developing the package

Everything runs from the repo root.

pnpm pkg:build       # clean build (tsc)
pnpm pkg:publish     # build + publish to npm

The build compiles src/ to dist/ using tsconfig.build.json. No bundler — just tsc.

Testing

cd packages/monitor
pnpm test            # run tests once
pnpm test:watch      # watch mode
pnpm typecheck       # type-check without emitting

Package structure

src/
  types.ts              # all public types (EventLevel, LogPayload, InitOptions, etc.)
  server/
    index.ts            # exports: init, log, POST
    init.ts             # console.error patching, process handlers, startup event
    log.ts              # custom server-side log()
    route.ts            # POST handler for client-side proxy
    batch.ts            # in-memory queue, 5s / 50-event flush
    send.ts             # fire-and-forget fetch to /api/ingest
  client/
    index.ts            # exports: Monitor, useMonitor
    context.tsx          # React context for app/env
    monitor.tsx          # error + unhandledrejection listeners, sendBeacon
    use-monitor.ts       # hook for custom client-side logging
  shared/
    serialize.ts         # safe meta serialization (circular refs, depth/size limits)

Two entry points: @lmstech/monitor/server and @lmstech/monitor/client.

Publishing

  1. Bump the version in packages/monitor/package.json.
  2. From the repo root: pnpm pkg:publish.

That's it. The script builds first, then publishes dist/ to npm.

First time only: make sure you're logged in (npm login) and the @lmstech npm org exists with public access. The publish script uses --access public for the scoped package.