Supportx_logogithub_logokeenthemes_logo

Authentication

January 9, 2024

NextAuth Setup

NextAuth.js is a complete open-source authentication solution for Next.js applications. It provides built-in support for multiple authentication providers and an easy-to-use API.

Step-by-Step Integration

Step 1: Install NextAuth

First, install the NextAuth package along with any provider packages you intend to use.

npm install next-auth @next-auth/providers

Step 2: Add your providers to the NextAuth configuration

Make sure that you add in the right modules into the application by copying the following folders in the root of the project. Please check if you can find the files

  • auth.tsx
  • src/app/api/auth/[...nextauth].ts
  • session-provider.tsx

Step 3: Add the NextAuth provider to your application

import NextAuth from 'next-auth' import Providers from 'next-auth/providers'