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

@sigauth/next

v0.1.3

Published

SigAuth Next.js Integration for lifting authentication and authorization

Readme

@sigauth/next

SigAuth integration for Next.js applications. This package provides a wrapper around @sigauth/core to simplify authentication and authorization in Next.js Server Components, API Routes, and Middleware.

Configuration

First, define your SigAuth options. It is recommended to do this in a shared constants file or a configuration module.

// utils/constants.ts
import { SigAuthOptions } from '@sigauth/core';

export const SIGAUTH_OPTIONS: SigAuthOptions = {
    appId: 'your-app-id',
    authServerUrl: 'https://auth.yourdomain.com',
    clientId: 'your-client-id',
    // ... other options
};

Usage

Initialization

The SigAuthNextWrapper is a singleton. You should initialize it once (recommended in root layout), typically in a helper function or when you first use it.

// lib/auth.ts
import { SigAuthNextWrapper } from '@sigauth/next';

export async function checkAuth() {
    return await SigAuthNextWrapper.getInstance().checkAuthentication();
}

Server Components (App Router)

Protect your Server Components by calling the check function. This will handle token validation, refreshing, and redirection to the login page if necessary.

import { checkAuth } from '@/lib/auth'; // Your helper
import { PermissionBuilder } from '@sigauth/next';

export default async function ProtectedPage() {
    const { user, sigauth } = await checkAuth("<your route>");

    // Check permissions
    const hasPermission = await sigauth?.hasPermission(
        new PermissionBuilder('view', 'your-app-id').withAssetId(123).build()
    );

    return (
        <div>
            <h1>Welcome, {user?.name}</h1>
            {hasPermission && <p>You can view this content.</p>}
        </div>
    );
}

Auth Callback Route (App Router)

Set up a route handler to handle the OIDC callback code exchange.

// app/api/sigauth/oidc/auth/route.ts
import { SigAuthNextWrapper } from '@sigauth/next';
import { SIGAUTH_OPTIONS } from '@/utils/constants';
import { NextRequest } from 'next/server';

export async function GET(request: NextRequest) {
    const wrapper = SigAuthNextWrapper.getInstance(SIGAUTH_OPTIONS);
    return wrapper.sigAuthExchange(request.url);
}

API Routes

In the App Router they share the same logic meaning you can use the checkAuthenticate() method the same way as before.

import { SIGAUTH_OPTIONS } from '@/utils/constants';
import { SigAuthNextWrapper } from '@sigauth/next';
import { NextRequest, NextResponse } from 'next/server';

export async function GET(req: NextRequest) {
    const result = await SigAuthNextWrapper.getInstance(SIGAUTH_OPTIONS).checkAuthentication('/api/example');
    if (result.user) {
        return NextResponse.json({ message: `Hello, ${result.user.name}! You are authenticated.` });
    } else {
        return NextResponse.json({ message: 'Hello, guest! You are not authenticated.' }, { status: 401 });
    }
}

SigAuthNextWrapper

  • static getInstance(opts?: SigAuthOptions): Returns the singleton instance. Options are required on the first call.
  • checkAuthenticationFromServer(): Authenticates in Server Components. Handles redirects and cookie setting (via next/headers and next/cookies).
  • checkAuthenticationFromApi(req, res): Authenticates in Pages Router API routes.
  • sigAuthExchange(url): Helper to exchange an auth code for tokens and set cookies.
  • getSigAuthVerifier(): Returns the underlying SigauthVerifier instance from @sigauth/core.