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

@auditauth/next

v0.2.0-beta.8

Published

AuditAuth NextJS SDK

Readme

@auditauth/next

@auditauth/next is the AuditAuth integration for Next.js App Router. It provides route handlers, auth middleware, protected server handlers, session helpers, and authenticated fetch wrappers.

Install

Install the package in your Next.js application.

npm install @auditauth/next

TypeScript import compatibility

@auditauth/next ships dual module output (ESM + CJS) with declaration files. You can import it in TypeScript projects with standard syntax:

import { createAuditAuthNext } from '@auditauth/next'

You do not need to append .js in consumer imports.

Create the AuditAuth provider

Create one shared instance with createAuditAuthNext().

// src/providers/auth.ts
import { createAuditAuthNext } from '@auditauth/next'

export const auditauth = createAuditAuthNext({
  apiKey: process.env.AUDITAUTH_API_KEY!,
  appId: process.env.AUDITAUTH_APP_ID!,
  baseUrl: 'http://localhost:3000',
  redirectUrl: 'http://localhost:3000/private',
})

Register auth API handlers

Expose the SDK handlers through a catch-all route.

// src/app/api/auditauth/[...auditauth]/route.ts
import { auditauth } from '@/providers/auth'

export const { GET, POST } = auditauth.handlers

The handler covers these endpoints:

  • GET /api/auditauth/login
  • GET /api/auditauth/callback
  • GET /api/auditauth/logout
  • GET /api/auditauth/portal
  • GET /api/auditauth/session
  • GET /api/auditauth/refresh
  • POST /api/auditauth/metrics

Protect private routes with middleware

Call auditauth.middleware() on route groups that require authentication.

// src/proxy.ts
import { NextResponse, type NextRequest } from 'next/server'
import { auditauth } from '@/providers/auth'

export async function proxy(request: NextRequest) {
  if (request.nextUrl.pathname.startsWith('/private')) {
    return auditauth.middleware(request)
  }

  return NextResponse.next()
}

Access session data in server components

Use auditauth.getSession() in server components, route handlers, or server actions.

const session = await auditauth.getSession()
if (!session) return null

Protect custom route handlers

Wrap handlers with auditauth.withAuthRequest() to enforce token validation and inject the verified token payload.

import { auditauth } from '@/providers/auth'
import { NextResponse } from 'next/server'

export const GET = auditauth.withAuthRequest(async (_req, _ctx, session) => {
  return NextResponse.json({ email: session.email })
})

Call protected APIs from the server

Use auditauth.fetch() for server-side requests with automatic refresh and request metrics.

const response = await auditauth.fetch('https://api.example.com/private')

Client helpers

For client-side navigation shortcuts, import these helpers:

  • login()
  • logout()
  • goToPortal()

You can also use AuditAuthGuard and useAuditAuth to gate client-rendered UI sections.

Compatibility

This package requires:

  • Node.js >=18.18.0
  • Next.js >=13
  • React >=18
  • React DOM >=18

Resources

  • Repository: https://github.com/nimibyte/auditauth-sdk
  • Documentation: https://docs.auditauth.com

Example

See examples/next for a complete App Router integration.

License

MIT