원클릭으로
mern-add-auth
Add authentication to a MERN project using NextAuth.js with OAuth and/or credentials.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Add authentication to a MERN project using NextAuth.js with OAuth and/or credentials.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Scaffold a pnpm + Turborepo MERN monorepo with Next.js, tooling, tests, CI, and optional GitHub repo creation.
Configure GitHub repository security with branch protection, Dependabot, security scanning, and CI workflows. Integrates with mern-scaffold, nean-scaffold, and iOS projects.
Harden a Vercel deployment with security headers, CSP, bot protection, and deployment configuration
Add authentication to an iOS app with Sign in with Apple, biometrics, and Keychain storage.
Scaffold a new feature with View, ViewModel, and tests following ios-std conventions.
Review iOS code for compliance with standards, NFRs, and security policy.
| name | mern-add-auth |
| description | Add authentication to a MERN project using NextAuth.js with OAuth and/or credentials. |
| argument-hint | [--providers google,github,credentials] [--with-user-model] |
| allowed-tools | Bash, Write, Read, Glob, Grep |
Add secure authentication to an existing MERN project using NextAuth.js (Auth.js).
--providers <list> — Comma-separated providers (default: google,github)
google, github, discord, credentials--with-user-model — Create User model in MongoDB for storing user dataapps/web/
├── app/api/auth/[...nextauth]/route.ts # NextAuth API route
├── src/lib/auth.ts # Auth config + providers
├── src/lib/auth-client.ts # Client-side helpers
├── src/components/auth/
│ ├── SignInButton.tsx # OAuth sign-in
│ ├── SignOutButton.tsx # Sign-out
│ └── UserMenu.tsx # User avatar + dropdown
├── src/server/db/models/user.ts # (if --with-user-model)
└── middleware.ts # Route protection
packages/shared/schemas/
└── user.ts # User schemas
.env.example # Updated with auth vars
# OAuth (per provider)
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
# NextAuth
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET= # Generate with: openssl rand -base64 32
next-auth, @auth/mongodb-adapter (if using DB)Middleware protects routes matching these patterns by default:
/dashboard/*/settings/*/api/* (except /api/auth/* and /api/health)Customize in middleware.ts.
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth';
const session = await getServerSession(authOptions);
if (!session) redirect('/api/auth/signin');
'use client';
import { useSession } from 'next-auth/react';
const { data: session, status } = useSession();
const session = await getServerSession(authOptions);
if (!session?.user?.id) {
return NextResponse.json(err('UNAUTHORIZED', 'Authentication required'), { status: 401 });
}
Summarize: providers configured, environment variables needed, protected routes, components available.
For templates and OAuth setup guides, see reference/mern-add-auth-reference.md