Search code examples
next.jsnext-auth

How to Fix NO_SECRET warning thrown by Next-Auth


I have a Next js application that uses Next Auth. While in development I continuously keep getting that warning stipulating that I need to set a secret but I don't know where I should set it.

Following this reference I see I just need to run openssl rand -base64 32 to get a secret but I have no Idea where to put it


Solution

  • In the [...nextauth].js outside provider and callback you can set the secret and it's value. As it is recommended to store such values in environment variable you can do the following

    export default NextAuth({
     
      providers: [ 
      ],
      callbacks: {
      },
      secret: process.env.JWT_SECRET,
    });