authjs-skills

Set up Auth.js v5 authentication in Next.js with Google OAuth and credentials provider.

Updated Sep 6, 2024
One-click install
npx skills add https://github.com/Jaylaelike/pm25-interactive-thaipbs-app --skill authjs-skills-jaylaelike
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: authjs-skills
Source: https://github.com/Jaylaelike/pm25-interactive-thaipbs-app/tree/main/.claude/skills/authjs-skills
Command: npx skills add https://github.com/Jaylaelike/pm25-interactive-thaipbs-app --skill authjs-skills-jaylaelike

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill streamlines implementing Auth.js v5 authentication in Next.js projects by providing a ready-to-use setup with Google OAuth, a credentials provider, environment configuration, and core API integration.

Core Features & Use Cases

  • Google OAuth integration: Sign-in with Google using OAuth2 for seamless user authentication.
  • Credentials provider: Support for username/password authentication with secure password handling guidance.
  • Environment configuration: Guidance on managing secrets (AUTH_SECRET) and provider credentials across development and production.
  • Core API integration: Examples showing how to wire Next.js API routes and middleware with NextAuth for protected resources.

Quick Start

Install NextAuth v5, configure environment variables (AUTH_SECRET, AUTH_GOOGLE_ID, AUTH_GOOGLE_SECRET), create an auth.ts at the project root with provider setup, add the Next.js API route for NextAuth, and run the dev server to enable authentication features.

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?

Setting up Auth.js v5 requires installing NextAuth, configuring AUTH_SECRET and Google OAuth credentials as environment variables, creating an auth.ts file with provider setup, and adding the Next.js API route for secure user login flows.

What environment variables do I need for Google OAuth in Next.js?

For Google OAuth in Next.js, you need to configure three environment variables: AUTH_SECRET, AUTH_GOOGLE_ID, and AUTH_GOOGLE_SECRET to manage secrets and provider credentials across development and production.

Can I use both Google OAuth and a credentials provider with NextAuth?

Yes, Auth.js v5 supports both Google OAuth and a credentials provider simultaneously. This setup allows seamless Google sign-in alongside username and password authentication with secure password handling.

Where should I place the auth.ts file when configuring Next.js authentication?

When configuring Next.js authentication with Auth.js v5, you should create the auth.ts file at the project root. This file contains the provider setup needed to wire Next.js API routes and middleware for protected resources.

Does Auth.js v5 work with TypeScript Next.js projects?

Yes, Auth.js v5 works with TypeScript Next.js projects, providing a ready-to-use setup that includes environment configuration and core API integration for secure authentication flows across modern Next.js apps.