# next-auth **Repository Path**: yazhitv/next-auth ## Basic Information - **Project Name**: next-auth - **Description**: No description available - **Primary Language**: Unknown - **License**: ISC - **Default Branch**: OrJDev/main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-04-19 - **Last Updated**: 2025-04-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
Authentication for Next.js
Open Source. Full Stack. Own Your Data.
## Overview NextAuth.js is a complete open source authentication solution for [Next.js](http://nextjs.org/) applications. It is designed from the ground up to support Next.js and Serverless. This is a monorepo containing the following packages / projects: 1. The primary `next-auth` package 2. A development test application 3. All `@next-auth/*-adapter` packages 4. The documentation site ## Getting Started ``` npm install --save next-auth ``` The easiest way to continue getting started, is to follow the [getting started](https://next-auth.js.org/getting-started/example) section in our docs. We also have a section of [tutorials](https://next-auth.js.org/tutorials) for those looking for more specific examples. See [next-auth.js.org](https://next-auth.js.org) for more information and documentation. ## Features ### Flexible and easy to use - Designed to work with any OAuth service, it supports OAuth 1.0, 1.0A and 2.0 - Built-in support for [many popular sign-in services](https://next-auth.js.org/providers) - Supports email / passwordless authentication - Supports stateless authentication with any backend (Active Directory, LDAP, etc) - Supports both JSON Web Tokens and database sessions - Designed for Serverless but runs anywhere (AWS Lambda, Docker, Heroku, etc…) ### Own your own data NextAuth.js can be used with or without a database. - An open source solution that allows you to keep control of your data - Supports Bring Your Own Database (BYOD) and can be used with any database - Built-in support for [MySQL, MariaDB, Postgres, Microsoft SQL Server, MongoDB and SQLite](https://next-auth.js.org/configuration/databases) - Works great with databases from popular hosting providers - Can also be used _without a database_ (e.g. OAuth + JWT) ### Secure by default - Promotes the use of passwordless sign-in mechanisms - Designed to be secure by default and encourage best practices for safeguarding user data - Uses Cross-Site Request Forgery (CSRF) Tokens on POST routes (sign in, sign out) - Default cookie policy aims for the most restrictive policy appropriate for each cookie - When JSON Web Tokens are enabled, they are encrypted by default (JWE) with A256GCM - Auto-generates symmetric signing and encryption keys for developer convenience - Features tab/window syncing and session polling to support short lived sessions - Attempts to implement the latest guidance published by [Open Web Application Security Project](https://owasp.org) Advanced options allow you to define your own routines to handle controlling what accounts are allowed to sign in, for encoding and decoding JSON Web Tokens and to set custom cookie security policies and session properties, so you can control who is able to sign in and how often sessions have to be re-validated. ### TypeScript NextAuth.js comes with built-in types. For more information and usage, check out the [TypeScript section](https://next-auth.js.org/getting-started/typescript) in the documentation. ## Example ### Add API Route ```javascript // pages/api/auth/[...nextauth].js import NextAuth from "next-auth" import AppleProvider from "next-auth/providers/apple" import GoogleProvider from "next-auth/providers/google" import EmailProvider from "next-auth/providers/email" export default NextAuth({ secret: process.env.SECRET, providers: [ // OAuth authentication providers AppleProvider({ clientId: process.env.APPLE_ID, clientSecret: process.env.APPLE_SECRET, }), GoogleProvider({ clientId: process.env.GOOGLE_ID, clientSecret: process.env.GOOGLE_SECRET, }), // Sign in with passwordless email link EmailProvider({ server: process.env.MAIL_SERVER, from: "