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

@lerix-dev/lerix-nextjs

v1.3.0

Published

Error tracking and Web Push notifications for Next.js apps, backed by the Lerix platform.

Downloads

344

Readme

@lerix-dev/lerix-nextjs

Error tracking and Web Push notifications for Next.js apps, backed by the Lerix platform. Built on @lerix-dev/lerix-react and @lerix-dev/lerix-core — works with both the App Router and the Pages Router.

Install

npm install @lerix-dev/lerix-nextjs

Setup

1. Configure your API key and project ID

Add to .env.local:

NEXT_PUBLIC_LERIX_API_KEY=your-api-key
NEXT_PUBLIC_LERIX_PROJECT_ID=your-project-id

These must be prefixed NEXT_PUBLIC_ — that's Next.js's own convention for env vars exposed to client-side code, required here since the SDK registers/reports from the browser.

2. Register the SDK (App Router)

Wrap your root layout in LerixNextProvider and LerixErrorBoundary:

import { LerixErrorBoundary, LerixNextProvider } from '@lerix-dev/lerix-nextjs';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        <LerixNextProvider>
          <LerixErrorBoundary fallback={<p>Something went wrong.</p>}>
            {children}
          </LerixErrorBoundary>
        </LerixNextProvider>
      </body>
    </html>
  );
}

LerixNextProvider reads NEXT_PUBLIC_LERIX_API_KEY/NEXT_PUBLIC_LERIX_PROJECT_ID automatically — pass options explicitly only if you want to override them (e.g. debugMode, a different project per environment).

For the Pages Router, do the same in pages/_app.tsx instead.

layout.tsx itself stays a Server Component — LerixNextProvider and LerixErrorBoundary are pre-marked 'use client' internally, so wrapping them around children doesn't force your whole tree to become client-only.

3. Report errors

'use client';
import { useLerix } from '@lerix-dev/lerix-nextjs';

export function MyComponent() {
  const lerix = useLerix();
  return <button onClick={() => lerix.throwError('Something went wrong')}>Test</button>;
}

LerixErrorBoundary only catches errors during rendering. For Next.js's own file-based error boundaries (error.tsx, global-error.tsx) — which you'll need for errors above where LerixErrorBoundary sits, e.g. in the root layout itself — call reportCaughtError directly:

'use client';
import { reportCaughtError } from '@lerix-dev/lerix-nextjs';
import { useEffect } from 'react';

export default function Error({ error }: { error: Error }) {
  useEffect(() => {
    reportCaughtError(error);
  }, [error]);

  return <p>Something went wrong.</p>;
}

Filtering errors

options also takes ignoreErrors and beforeSend, applied to every report (LerixErrorBoundary, reportCaughtError in error.tsx, global handlers). ignoreErrors runs first: a string drops any error whose message contains it (case-insensitive), a RegExp drops any message it matches (empty strings are skipped). beforeSend gets a LerixErrorEvent and returns it (optionally modified) to send, or null to drop it; if it throws, the original is sent.

Functions and RegExps can't be passed as props from a Server Component, so set these options in a small client component and use it in layout.tsx in place of LerixNextProvider:

'use client';
import { LerixNextProvider } from '@lerix-dev/lerix-nextjs';

export function Lerix({ children }: { children: React.ReactNode }) {
  return (
    <LerixNextProvider
      options={{
        ignoreErrors: ['ResizeObserver loop', /^ChunkLoadError/],
        beforeSend: (event) => (event.message.includes('extension://') ? null : event),
      }}
    >
      {children}
    </LerixNextProvider>
  );
}

4. Push notifications

cp node_modules/@lerix-dev/lerix-core/sw/lerix-sw.js your-app/public/lerix-sw.js

Generate a Web Push key from the dashboard: Notifications → Settings → Web Push → Generate keys.

'use client';
import { useLerixNotifications } from '@lerix-dev/lerix-nextjs';

export function MyComponent() {
  const notifications = useLerixNotifications();
  return <button onClick={() => notifications.subscribe()}>Enable notifications</button>;
}

API

| Export | Description | |---|---| | LerixNextProvider | Registers the SDK at mount, reading config from NEXT_PUBLIC_* env vars by default. | | LerixErrorBoundary | Catches React render-tree errors and reports them. | | useLerix() | Returns the Lerix facade — throwError, getUserId, setUser/clearUser, reRegisterUser, etc. | | useLerixNotifications() | Returns the notifications API — subscribe, checkPermissionStatus, getRegisteredTokenId, topics, etc. | | reportCaughtError(error) | Reports an already-caught error directly — for use in Next's own error.tsx/global-error.tsx. |

Requirements

  • Next.js 13+
  • React 18+