This is an example of of using NextAuth.js Credentials provider to implement sign-up and sign-in using email and password. The intent of this example is to show the authentication process, including account creation, sign-in, sign-out and saving user session to the browser with Recoil and Recoil Persist.
Clone the repository:
git clone https://github.com/Issam-Boubcher/credentials-next-auth-example.git
Change the name of .env.local.example
to .env.local
, and fill in the following values:
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=somereallysecretsecret
DATABASEURL=YourDatabaseURL
Note: If you're planning to use a database service other than MySQL, make sure to update datasource provider
in prisma/schema.prisma
.
You can use the following commands to run the example:
npm install
npx prisma generate
npm run dev
A live demo of the example can be found here.
ISC