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

@zalt.io/next

v1.0.1

Published

Zalt.io Authentication SDK - Next.js middleware and SSR support

Readme

@zalt/next

Next.js integration for Zalt.io authentication. Middleware, SSR, and server components.

Installation

npm install @zalt/core @zalt/react @zalt/next

Quick Start

1. Add Provider

// app/layout.tsx
import { ZaltProvider } from '@zalt/react';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        <ZaltProvider realmId={process.env.NEXT_PUBLIC_ZALT_REALM_ID!}>
          {children}
        </ZaltProvider>
      </body>
    </html>
  );
}

2. Add Middleware

// middleware.ts
import { zaltMiddleware } from '@zalt/next';

export default zaltMiddleware({
  publicRoutes: ['/', '/sign-in', '/sign-up'],
  signInUrl: '/sign-in',
});

export const config = {
  matcher: ['/((?!_next|.*\\..*).*)'],
};

3. Use Server Helpers

// app/dashboard/page.tsx
import { getAuth, currentUser } from '@zalt/next';

export default async function DashboardPage() {
  const { userId } = await getAuth();
  const user = await currentUser();

  return <h1>Welcome, {user?.email}</h1>;
}

Features

  • 🛡️ Middleware - Protect routes automatically
  • 🖥️ SSR - Server-side authentication
  • 🍪 Secure Cookies - httpOnly, secure, sameSite
  • Edge Runtime - Works on Vercel Edge
  • 📦 Lightweight - < 2KB gzipped

API Reference

zaltMiddleware

Protect routes with middleware.

import { zaltMiddleware } from '@zalt/next';

export default zaltMiddleware({
  // Routes that don't require authentication
  publicRoutes: ['/', '/sign-in', '/sign-up', '/api/webhooks(.*)'],
  
  // Where to redirect unauthenticated users
  signInUrl: '/sign-in',
  
  // Routes to completely ignore (static files, etc.)
  ignoredRoutes: ['/api/health'],
  
  // Custom redirect after sign in
  afterSignInUrl: '/dashboard',
});

Route Patterns

publicRoutes: [
  '/',                    // Exact match
  '/blog/(.*)',          // Regex: all blog routes
  '/api/public/(.*)',    // Regex: public API routes
]

getAuth

Get authentication state on the server.

import { getAuth } from '@zalt/next';

export default async function Page() {
  const { userId, sessionId } = await getAuth();
  
  if (!userId) {
    redirect('/sign-in');
  }
  
  return <div>User ID: {userId}</div>;
}

currentUser

Get full user object on the server.

import { currentUser } from '@zalt/next';

export default async function Page() {
  const user = await currentUser();
  
  return (
    <div>
      <p>Email: {user?.email}</p>
      <p>Name: {user?.profile?.firstName}</p>
    </div>
  );
}

API Route Protection

// app/api/protected/route.ts
import { getAuth } from '@zalt/next';
import { NextResponse } from 'next/server';

export async function GET() {
  const { userId } = await getAuth();
  
  if (!userId) {
    return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
  }
  
  return NextResponse.json({ userId });
}

Environment Variables

# Required
NEXT_PUBLIC_ZALT_REALM_ID=your-realm-id

# Optional
ZALT_API_URL=https://api.zalt.io

Cookie Configuration

Cookies are automatically configured for security:

{
  httpOnly: true,
  secure: process.env.NODE_ENV === 'production',
  sameSite: 'lax',
  path: '/',
  maxAge: 7 * 24 * 60 * 60, // 7 days
}

Edge Runtime

Works with Next.js Edge Runtime:

// middleware.ts
export const config = {
  matcher: ['/((?!_next|.*\\..*).*)'],
  runtime: 'edge',
};

TypeScript

import type { ZaltMiddlewareConfig } from '@zalt/next';

const config: ZaltMiddlewareConfig = {
  publicRoutes: ['/'],
  signInUrl: '/sign-in',
};

License

MIT