authjs-skills

Configures Auth.js v5 authentication for Next.js App Router apps.

22|7|Updated Dec 20, 2025
One-click install
npx skills add https://github.com/gocallum/nextjs16-agent-skills --skill authjs-skills
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: authjs-skills
Source: https://github.com/gocallum/nextjs16-agent-skills/tree/main/skills/authjs-skills
Command: npx skills add https://github.com/gocallum/nextjs16-agent-skills --skill authjs-skills

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill streamlines authenticating Next.js apps by providing Auth.js v5 integration with Google OAuth and Credentials provider, reducing setup overhead and ensuring up-to-date patterns for secure sessions.

Core Features & Use Cases

  • Unified auth: Single auth() export for multiple contexts (server, middleware, client) across Next.js App Router.
  • Provider integrations: Google OAuth, Credentials, and optional database adapters.
  • Environment & security: Guidance on AUTH_SECRET, environment variables, and secure session handling.
  • Use Case: Migrate a Next.js project from v4 to v5 with minimal changes while preserving strong security practices.

Quick Start

Install dependencies and add a basic NextAuth config using Google and Credentials providers. Create auth.ts at the project root, configure the auth() export, and set up API routes and middleware as shown in the examples.

Frequently Asked Questions about authjs-skills

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Auth.js v5 authentication in a Next.js app?

Auth.js v5 authentication in Next.js requires creating an auth.ts config file at your project root with the auth() export, configuring providers like Google OAuth or Credentials, setting the AUTH_SECRET environment variable, and integrating API routes and middleware. This streamlines session management across server, middleware, and client contexts in App Router projects.

Can I use Google OAuth with Auth.js v5 in Next.js?

Yes. Auth.js v5 supports Google OAuth as a built-in provider for Next.js. You configure it in your auth.ts file with Google credentials from your OAuth application, then Auth.js handles the sign-in flow, token exchange, and session creation automatically.

What's the difference between Auth.js v5 and v4 for Next.js?

Auth.js v5 introduces a unified auth() export that works across server, middleware, and client contexts in App Router, replacing separate APIs in v4. Migration to v5 preserves security practices while simplifying integration patterns and reducing configuration overhead for modern Next.js projects.

Do I need a database adapter to use Auth.js v5 with Next.js?

Database adapters are optional in Auth.js v5. You can start with credentials or OAuth providers without a database for basic authentication. Database adapters become necessary only when you need persistent user data, session storage beyond defaults, or advanced features like account linking.

How do I handle session management securely with Auth.js v5?

Auth.js v5 manages sessions through environment variables like AUTH_SECRET for encryption and provides middleware integration for edge-runtime readiness. Configure your providers, set secure environment variables, and use the middleware to protect routes while Auth.js handles token validation and session lifecycle.

Can I use a credentials provider with Auth.js v5 in Next.js?

Yes. Auth.js v5 includes a Credentials provider for username/password authentication alongside OAuth. You configure it in auth.ts with custom validation logic, and it integrates with the same session and middleware patterns as Google OAuth or other providers.