AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Mern Add Auth

skill-edfenton-claude-skills-mern-add-auth · by edfenton

Add authentication to a MERN project using NextAuth.js with OAuth and/or credentials.

No reviews yet
0 installs
19 views
0.0% view→install

Install

$ agentstack add skill-edfenton-claude-skills-mern-add-auth

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets Used
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-edfenton-claude-skills-mern-add-auth)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
5mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Mern Add Auth? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Purpose

Add secure authentication to an existing MERN project using NextAuth.js (Auth.js).

Arguments

  • --providers — Comma-separated providers (default: google,github)
  • Options: google, github, discord, credentials
  • --with-user-model — Create User model in MongoDB for storing user data

What gets created

apps/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

Environment variables required

# 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

Workflow

  1. Install dependencies: next-auth, @auth/mongodb-adapter (if using DB)
  2. Create auth config with selected providers
  3. Create API route handler
  4. Create auth components
  5. Create middleware for protected routes
  6. Update env.ts schema with auth variables
  7. Create User model (if --with-user-model)
  8. Add session provider to app layout
  9. Run tests to verify

Protected routes

Middleware protects routes matching these patterns by default:

  • /dashboard/*
  • /settings/*
  • /api/* (except /api/auth/* and /api/health)

Customize in middleware.ts.

Usage patterns

Server Component

import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth';

const session = await getServerSession(authOptions);
if (!session) redirect('/api/auth/signin');

Client Component

'use client';
import { useSession } from 'next-auth/react';

const { data: session, status } = useSession();

API Route

const session = await getServerSession(authOptions);
if (!session?.user?.id) {
  return NextResponse.json(err('UNAUTHORIZED', 'Authentication required'), { status: 401 });
}

Output

Summarize: providers configured, environment variables needed, protected routes, components available.

Reference

For templates and OAuth setup guides, see reference/mern-add-auth-reference.md

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.