XSS Protection
DOMPurify sanitization on all inputs. CSP headers via proxy.ts. No raw strings in the DOM.
NextForge is a battle-hardened Next.js scaffold — auth, database clients, reusable components, and full XSS/SQLi/CSRF protection wired up before you write a single line of business logic.
// features
Stop configuring, start building. Every critical system is production-ready before you touch business logic.
DOMPurify sanitization on all inputs. CSP headers via proxy.ts. No raw strings in the DOM.
NextAuth v5 with Credentials + Google. JWT sessions, email verification, password reset — all wired.
MongoDB (Mongoose), PostgreSQL (node-pg), Supabase, and Firebase — each with connection pooling and safe query patterns.
Upstash Redis sliding window on all auth routes. Graceful no-op fallback when Redis is unavailable.
OTP delivery for email verification and password reset. Inline-styled HTML templates, spam-filter safe.
Button, Input, Loader, Toast, Modal, Navbar, Footer — themed via CSS variables, no hardcoded colors.
All mutations use Next.js server actions with useTransition — buttons auto-disabled during pending state.
Every component built base → sm → md → lg. No layout surprises on any screen size.
// how it works
Clone. Enter your folder. Choose your database. Install. Ship.
Get the full scaffold with all auth flows, security layers, and UI components already wired.
Move into your new project directory so setup and install commands target the right workspace.
Interactive CLI — pick MongoDB, Supabase, or Firebase. The script copies the right files, strips unused dependencies, and generates your .env.local.example. Deletes itself when done.
Fill in AUTH_SECRET, your DB credentials, Resend API key, and Upstash Redis. Every variable is documented in .env.local.example.
Auth works. Email flows work. Security is on. Your job is business logic — nothing else.
// what's included
Login flows. Email verification. Password reset. Rate limiting. Input validation. Security protections. It's already done.
core framework
Pick one — the rest is stripped clean
full stack
| Category | Technology |
|---|---|
| Framework | Next.js 16 |
| Auth | NextAuth v5 |
| Database | MongoDB + Mongoose · Supabase · Firebase (pick one) |
| Resend | |
| Rate Limiting | Upstash Redis |
| Validation | Zod |
| Styling | Tailwind CSS v4 |
| Icons | Lucide React |
| Passwords | bcryptjs (cost 12) |
| Language | TypeScript (strict) |
// security
It's the default. Every layer hardened before you write a single line of business logic.
NextForge applies security at every tier. proxy.ts handles route protection and security headers. Server actions re-validate sessions independently - never trust proxy.ts alone. Zod schemas block malformed data before it reaches the database. OTPs are hashed with SHA-256 and verified with timing-safe comparison. Passwords use bcrypt at cost factor 12.
OTP expiry checked at query time - not just on creation
escapeHTML() applied to all user-supplied string inputs server-side. CSP headers block unauthorized script execution.
Session checked in proxy.ts AND independently inside every server action. A compromised middleware never bypasses action-level guards.
stripMongoOperators() strips all $-prefixed and dot-notation keys from user input before any MongoDB query. Supabase uses parameterized queries.
6-digit OTPs generated via crypto.randomInt (CSPRNG). SHA-256 hash stored - plaintext never persisted. Verified with crypto.timingSafeEqual.
10-minute expiry checked at query time with $gt: new Date(). TTL index on MongoDB auto-deletes expired documents. Used flag prevents replay.
X-Frame-Options: DENY, X-Content-Type-Options: nosniff, Referrer-Policy: strict-origin-when-cross-origin, HSTS in production.
Upstash Redis sliding window - 5 req/min on auth routes, 3 req/min on OTP endpoints. Graceful no-op fallback if Redis is unavailable.
Passwords use select: false on Mongoose queries. Raw errors never reach the client. process.env.NODE_ENV gates dev-only error output. Email enumeration prevented on password reset and OTP resend.
Star the repo to keep up as NextForge grows - new database variants, components, and improvements land regularly.
MIT licence - free for personal and commercial use
github.com/Talhaahmad9/nextforge