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

nextjs-auth-module

v1.1.0

Published

Complete authentication module for Next.js with PostgreSQL, JWT, and password reset functionality

Readme

Next.js Auth Module

A complete, production-ready authentication module for Next.js applications with PostgreSQL.

Features

  • ✅ User registration with email/password
  • ✅ User login with JWT tokens
  • ✅ Password reset with email notifications
  • ✅ Protected routes
  • ✅ PostgreSQL database support (Neon, AWS RDS, etc.)
  • ✅ JWT authentication
  • ✅ Bcrypt password hashing
  • ✅ Ready-to-use components
  • ✅ TypeScript ready (including .d.ts files)

Installation

Quick Setup (Recommended)

1 npx create-next-app@latest my-app
cd my-app
npm install nextjs-auth-module
npx setup-auth


# When prompted:
# ✓ Would you like to use TypeScript? … No
# ✓ Would you like to use ESLint? … Yes  
# ✓ Would you like to use Tailwind CSS? … Yes
# ✓ Would you like to use `src/` directory? … No
# ✓ Would you like to use App Router? … Yes
# ✓ Would you like to customize the default import alias (@/*)? … No

# Navigate into the new project
cd my-new-auth-app

3.  # Install all authentication dependencies
npm install bcryptjs jsonwebtoken pg nodemailer @heroicons/react dotenv

# Install dev dependencies (if needed)
npm install -D @types/bcryptjs @types/jsonwebtoken



4. # Install the auth module package
npm install nextjs-auth-package

# Verify it worked
npm list --depth=0 | grep nextjs-auth
# Should show: [email protected]


5. # Run the setup to copy all auth files
npx setup-auth

# Or if that doesn't work, run:
node node_modules/nextjs-auth-package/bin/setup-auth.js

6. 7 . create database 

    run  schema.sql file on sql editor on neon


7. # Create .env.local from example

copy file from .env.example   to  .env.local

and edit en.local to real data such as db URL  and all place holder file with real data

# To generate JWT secret 
run in bash

node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

8 . npm run dev
Open http://localhost:3000


📁 Project Structure
text
your-project/
├── app/
│   ├── api/
│   │   ├── login/route.js
│   │   ├── register/route.js
│   │   ├── forgot-password/route.js
│   │   └── reset-password/route.js
│   ├── login/page.jsx
│   ├── register/page.jsx
│   ├── forgot-password/page.jsx
│   ├── reset-password/page.jsx
│   └── layout.jsx
├── context/
│   └── AuthContext.jsx
├── lib/
│   ├── db.js
│   ├── auth.js
│   └── email.js
├── scripts/
│   └── init-db.js
├── .env.local
└── package.json

📧 Email Configuration (Gmail)
To enable password reset emails:

Enable 2-Step Verification on your Google account

Generate an App Password:

Go to https://myaccount.google.com/apppasswords

Select "Other" and name it "NextJS Auth"

Copy the 16-character password

Update .env.local:

env
EMAIL_USER="[email protected]"
EMAIL_PASS="16-character-app-password"
🧪 Development Without Email
For testing without email, the reset link will be printed in your terminal:

text
🔐 ========== PASSWORD RESET LINK ==========
Reset URL: http://localhost:3000/reset-password?token=abc123
==========================================
🚢 Deployment
Deploy to Vercel
Push your code to GitHub

Import project to Vercel

Add environment variables in Vercel dashboard

Deploy

Environment Variables on Vercel
env
DATABASE_URL=your_neon_postgres_url
JWT_SECRET=your_jwt_secret
[email protected]
EMAIL_PASS=your_app_password
NEXT_PUBLIC_APP_URL=https://your-domain.vercel.app