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

@centinel/nextjs

v1.2.2

Published

Package designed to add Centinel Analytica functionality to Next.js applications

Downloads

222

Readme

Centinel Analytica Next.js Integration

Bot protection middleware for Next.js applications.

Installation

npm install @centinel/nextjs

Setup

1. Environment Variables

CENTINEL_SITE_KEY=your_site_key_here
CENTINEL_SECRET_KEY=your_secret_key_here
NEXT_PUBLIC_CENTINEL_SITE_KEY=your_site_key_here

2. Client Script

// app/layout.tsx
import { CentinelLayout } from '@centinel/nextjs';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html>
      <body>
        <CentinelLayout siteKey={process.env.CENTINEL_SITE_KEY!}>
          {children}
        </CentinelLayout>
      </body>
    </html>
  );
}

3. Middleware

Simple Middleware

import { createCentinelMiddlewareFromEnv } from '@centinel/nextjs';
import { NextRequest } from 'next/server';

const centinelMiddleware = createCentinelMiddlewareFromEnv();

export default async function middleware(request: NextRequest) {
  const result = await centinelMiddleware(request);
  return result.response;
}

export const config = {
  matcher: ['/api/:path*', '/dashboard/:path*']
};

With Multiple Middlewares

import { createCentinelMiddleware } from '@centinel/nextjs';
import { NextRequest, NextResponse } from 'next/server';

const centinelMiddleware = createCentinelMiddleware({
  siteKey: process.env.CENTINEL_SITE_KEY!,
  secretKey: process.env.CENTINEL_SECRET_KEY!
});

export default async function middleware(request: NextRequest) {
  const result = await centinelMiddleware(request);

  if (result.should_intercept) {
    return result.response;
  }

  // Your other middleware logic
  return NextResponse.next();
}

export const config = {
  matcher: ['/api/:path*', '/dashboard/:path*']
};

Manual Validation (API Routes)

// app/api/login/route.ts
import { createRequestValidatorFromEnv } from '@centinel/nextjs';
import { NextRequest, NextResponse } from 'next/server';

const { isBot } = createRequestValidatorFromEnv();

export async function POST(request: NextRequest) {
  if (await isBot(request)) {
    return NextResponse.json({ error: 'Blocked' }, { status: 403 });
  }
  return handleLogin(request);
}

Advanced

CentinelResult

interface CentinelResult {
  response: NextResponse;
  decision: 'allow' | 'block' | 'redirect' | 'not_matched';
  should_intercept: boolean;
}
  • should_intercept: trueblock or redirect (return immediately)
  • should_intercept: falseallow or not_matched (continue)

CentinelMiddleware Class

import { CentinelMiddleware } from '@centinel/nextjs';

const centinel = new CentinelMiddleware({
  siteKey: process.env.CENTINEL_SITE_KEY!,
  secretKey: process.env.CENTINEL_SECRET_KEY!,
  timeout: 1000,  // ms (default: 500)
  debugMode: true
});

const result = await centinel.validate({ request });

Check Cookie in API Routes

export async function POST(request: NextRequest) {
  if (!request.cookies.get('_centinel')) {
    return NextResponse.json({ error: 'Blocked' }, { status: 403 });
  }
  // ...
}