auth-patterns
Skill by davepoon
Guides Next.js developers through authentication and authorization with NextAuth.js (Auth.js). Covers setup, middleware route protection, session handling, JWT and database sessions, and role-based access. Written for developers adding login flows to Next.js apps.
Install auth-patterns
Built from the published package, never by AI.
git clone --depth 1 https://github.com/davepoon/buildwithclaude /tmp/buildwithclaude && mkdir -p ~/.claude/skills && cp -r /tmp/buildwithclaude/plugins/nextjs-expert/skills/auth-patterns ~/.claude/skills/auth-patternsRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/davepoon/buildwithclaude /tmp/buildwithclaude && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/buildwithclaude/plugins/nextjs-expert/skills/auth-patterns ~/.gemini/antigravity-cli/skills/auth-patternsAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill is a reference guide for authentication and authorization in Next.js applications. It focuses on NextAuth.js (Auth.js), with setup code for version 5 installed as next-auth@beta, a GitHub provider, and a credentials provider that checks a user's password. It also compares other options such as Clerk, Lucia, Supabase Auth, and custom JWT.
It shows how to protect routes with middleware, including a cookie check and JWT verification with jose, and how to read session data in server and client components. It also covers role-based access control, JWT versus database session storage, a custom login page, and a short list of security practices. It is aimed at developers adding login or access rules to a Next.js app.
Written from the project's SKILL.md and checked against it.
What it can do
- NextAuth.js v5 setupShows how to configure NextAuth with GitHub and credentials providers.
- Middleware route protectionShows how to guard routes such as /dashboard and /api/protected with middleware.
- Session data accessShows how to read the session in server components and client components.
- Sign in and sign outProvides form-based sign in and sign out button examples using server actions.
- JWT verificationShows how to verify a token in middleware using the jose library.
- Role-based access controlShows how to add a role to the session and restrict admin-only components.
- Session storage optionsCompares stateless JWT sessions with database sessions using the Prisma adapter.
- Custom login pageShows a login page that redirects back to a callback URL after sign in.
- Security best practicesLists practices such as HTTPS, secure cookie flags, and password hashing.
What you need
- Next.js application
- npm to install next-auth@beta
- GitHub OAuth app client ID and secret for the GitHub provider
- JWT_SECRET environment variable for JWT verification
- Prisma client for database sessions
Try asking
- How do I protect /dashboard routes in Next.js with middleware?
- Set up NextAuth.js v5 with GitHub login in my Next.js app.
- Show me how to add an admin role to the NextAuth session.
Good to know
- Code samples target NextAuth.js v5, installed as next-auth@beta.
- The skill lists reference files such as references/middleware-auth.md that are not included in this source.
- Security measures such as rate limiting and password hashing are listed as practices, not implemented in the samples.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: plugins/nextjs-expert/skills/auth-patterns/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md8 KB -
examples/nextauth-setup.md13 KB -
references/middleware-auth.md11 KB -
references/session-management.md10 KB
Alternatives to auth-patterns
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
auth-patterns: common questions
What does the auth-patterns skill cover?
It covers authentication and authorization in Next.js, with a focus on NextAuth.js (Auth.js). It also includes middleware protection, session management, and role-based access control.
Does it support JWT and database sessions?
Yes. The source shows a JWT (stateless) session strategy and a database session strategy using the Prisma adapter.
Which auth libraries does it mention?
The source lists NextAuth.js (Auth.js), Clerk, Lucia, Supabase Auth, and custom JWT as options.
How do I install auth-patterns?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is auth-patterns free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is auth-patterns safe to use?
It scores 88 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to auth-patterns?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
