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

@callmedaniel/nextauth-cli

v1.0.1

Published

πŸ” Interactive CLI wizard to scaffold NextAuth.js authentication in seconds

Readme

πŸ” NextAuth CLI

Interactive CLI wizard to scaffold NextAuth.js authentication in your Next.js project in seconds!

npm version GitHub license


πŸš€ Features

βœ… Interactive Setup Wizard - Answer a few questions and get your auth system in seconds
βœ… Multiple Providers - Google, GitHub, Apple, Facebook, Email Magic Links, Credentials
βœ… Session Strategies - JWT (stateless) or Database (stateful)
βœ… Database Support - Prisma with PostgreSQL, MySQL, MongoDB, SQLite
βœ… RBAC - Role-Based Access Control utilities included
βœ… Email Verification - Ready-to-use email verification setup
βœ… Protected Routes - Middleware and component examples
βœ… API Protection - Utilities to protect API routes
βœ… Auto-Install - Optionally auto-install dependencies


πŸ“¦ Installation

Global Installation (Recommended)

npm install -g @callmedaniel/nextauth-cli

Local Installation

npm install --save-dev @callmedaniel/nextauth-cli

🎯 Quick Start

1. Create a Next.js Project

npx create-next-app@latest my-auth-app
cd my-auth-app

2. Run the NextAuth CLI

npx @callmedaniel/nextauth-cli

3. Answer the Interactive Questions

βœ“ Select authentication providers
βœ“ Choose session strategy (JWT or Database)
βœ“ Select database if needed
βœ“ Setup RBAC?
βœ“ Setup Email Verification?
βœ“ Generate protected routes?
βœ“ Install dependencies?

4. Configure Environment Variables

Copy .env.example to .env.local and fill in your OAuth credentials:

cp .env.example .env.local

5. Start Your Development Server

npm run dev

Visit http://localhost:3000/auth/signin to see your auth system in action!


πŸ“ Generated Files

The CLI generates the following structure:

app/
β”œβ”€β”€ api/auth/[...nextauth]/
β”‚   └── route.ts                 # NextAuth configuration
β”œβ”€β”€ dashboard/
β”‚   └── page.tsx                 # Protected route example

components/
β”œβ”€β”€ auth/
β”‚   └── SignIn.tsx               # Sign-in component

lib/
β”œβ”€β”€ auth/
β”‚   β”œβ”€β”€ rbac.ts                  # Role-Based Access Control
β”‚   β”œβ”€β”€ email-verification.ts    # Email verification utilities
β”‚   └── protectedApi.ts          # API protection utilities

middleware.ts                     # Route protection middleware
prisma/
β”œβ”€β”€ schema.prisma                # Database schema (if DB selected)

.env.example                      # Environment variables template

πŸ” Authentication Providers

Google OAuth

Requires: GOOGLE_ID, GOOGLE_SECRET

GitHub OAuth

Requires: GITHUB_ID, GITHUB_SECRET

Apple OAuth

Requires: APPLE_ID, APPLE_TEAM_ID, APPLE_KEY_ID, APPLE_PRIVATE_KEY

Facebook OAuth

Requires: FACEBOOK_ID, FACEBOOK_SECRET

Email Magic Links

Requires: EMAIL_SERVER, EMAIL_FROM

Credentials (Username/Password)

No additional setup required. Implement your own authorization logic.


πŸ›‘οΈ RBAC (Role-Based Access Control)

The CLI generates RBAC utilities for role-based access control:

import { hasPermission, hasRole } from '@/lib/auth/rbac';

// Check if user has a specific permission
if (hasPermission(userRole, 'write:all')) {
  // Allow action
}

// Check if user has a specific role
if (hasRole(userRole, 'admin')) {
  // Admin-only action
}

πŸ“§ Email Verification

The CLI includes email verification utilities:

import { generateVerificationToken, verifyEmailToken } from '@/lib/auth/email-verification';

// Generate a verification token
const token = generateVerificationToken('[email protected]');

// Verify the token
const result = verifyEmailToken(token);
if (result.valid) {
  console.log('Email verified:', result.email);
}

πŸ”’ Protected Routes

The generated middleware protects routes automatically:

// middleware.ts already set up to protect:
// - /dashboard/*
// - /profile/*
// - /admin/*

πŸ› οΈ API Route Protection

Protect your API routes:

import { requireAuth } from '@/lib/auth/protectedApi';

export async function GET(request) {
  const session = await requireAuth(request);
  if (session instanceof Response) return session; // Unauthorized

  // Your protected API logic
  return Response.json({ message: 'Success' });
}

πŸ“š NextAuth Documentation

For more information about NextAuth.js, visit:


🀝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.


πŸ“„ License

MIT License - see LICENSE file for details


πŸ™‹ Support

If you have questions or issues:

  1. Check the NextAuth.js Documentation
  2. Open an issue on GitHub
  3. Start a discussion on GitHub Discussions

Made with ❀️ by callmedaniel-del