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

@zetalyx/nextjs

v2.2.1

Published

Zetalyx SDK for Next.js - full-stack error & event tracking

Readme

@zetalyx/nextjs

Next.js integration for Zetalyx — full-stack error capture with minimal setup.

Installation

npm install @zetalyx/nextjs @zetalyx/react @zetalyx/browser @zetalyx/node

Minimum Setup (2 files + env)

This is all you need for full-stack error capture:

1. Environment Variables

# .env.local

# Server-side (API token)
ZETALYX_PROJECT_TOKEN=ptk_api_live_acme-corp_web-app_q7r8...

# Client-side (SDK token)
NEXT_PUBLIC_ZETALYX_PROJECT_TOKEN=ptk_sdk_live_acme-corp_web-app_a1b2...

# Optional
ZETALYX_DEBUG=true
ZETALYX_ENDPOINT=https://your-custom-api.example.com

2. Server-side: instrumentation.ts

// instrumentation.ts
import { initZetalyxServer } from '@zetalyx/nextjs';

export function register() {
  initZetalyxServer();
}

Captures all uncaught exceptions and unhandled promise rejections on the server.

3. Client-side: add provider to layout

// app/layout.tsx
import { ZetalyxClientProvider } from '@zetalyx/nextjs';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html>
      <body>
        <ZetalyxClientProvider errorBoundary>
          {children}
        </ZetalyxClientProvider>
      </body>
    </html>
  );
}

Auto-captures window errors, unhandled promise rejections, and React render errors.

That's it. You now have full-stack error capture.

Removal

  1. Delete instrumentation.ts (or remove the initZetalyxServer() call)
  2. Remove <ZetalyxClientProvider> from layout.tsx
  3. Delete the env vars

No business logic files are touched. No per-route wrappers to revert.


Optional Enhancements

Everything below is optional — use only if you need more granular tracking.

Middleware tracking (request-level metrics)

// middleware.ts
import { withZetalyxMiddleware } from '@zetalyx/nextjs';
import { NextResponse, type NextRequest } from 'next/server';

function middleware(request: NextRequest) {
  return NextResponse.next();
}

export default withZetalyxMiddleware(middleware);

Tracks: HTTP method, path, status code, duration, client IP, user agent.

Per-route API wrapping (route-specific metadata)

// app/api/users/route.ts
import { withZetalyx } from '@zetalyx/nextjs';
import { NextResponse } from 'next/server';

export const GET = withZetalyx(async (request) => {
  const users = await db.getUsers();
  return NextResponse.json(users);
});

Adds per-route context: method, path, status code, duration.

Server action wrapping (action-specific metadata)

// app/actions.ts
'use server';

import { withZetalyxAction } from '@zetalyx/nextjs';

export const createPost = withZetalyxAction(async (formData: FormData) => {
  const title = formData.get('title') as string;
  return await db.createPost({ title });
});

Adds action name to error reports.

Error page hook (error page context)

// app/error.tsx
'use client';

import { useZetalyxError } from '@zetalyx/nextjs';

export default function Error({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  useZetalyxError(error);

  return (
    <div>
      <h2>Something went wrong</h2>
      <button onClick={reset}>Try again</button>
    </div>
  );
}

Global error component (catch-all UI)

// app/global-error.tsx
export { ZetalyxGlobalError as default } from '@zetalyx/nextjs';

Provider Props

ZetalyxClientProvider accepts all @zetalyx/react provider props:

<ZetalyxClientProvider
  projectToken="ptk_sdk_live_..."   // Optional if NEXT_PUBLIC_ZETALYX_PROJECT_TOKEN is set
  userId={session?.user?.id}         // Optional user identification
  autoCapture={true}                 // Auto-capture window errors (default: true)
  captureClicks={false}              // Auto-track clicks on interactive elements (default: false)
  errorBoundary={true}               // Wrap children in error boundary (default: false)
  errorFallback={<ErrorUI />}        // Custom error boundary fallback
  onError={(error, info) => {}}      // Error boundary callback
  enabled={true}                     // Kill switch — false = zero side effects (default: true)
>
  {children}
</ZetalyxClientProvider>

Disabling the SDK

Set enabled={false} on the provider (client) or pass enabled: false to initZetalyxServer() config (server). When disabled:

  • No event listeners attached
  • No network requests made
  • No timers started
  • All tracking methods are silent no-ops
  • Provider renders children without side effects

This lets you disable Zetalyx without removing code — useful for dev/staging.

Custom Endpoint

Override the default API endpoint via env var or config:

ZETALYX_ENDPOINT=http://localhost:3001

Or pass directly:

initZetalyxServer({ endpoint: 'http://localhost:3001' });
<ZetalyxClientProvider endpoint="http://localhost:3001">

License

MIT