Skip to content

a small repository built to test out basic next auth features

Notifications You must be signed in to change notification settings

lmac-1/next-auth-practice

Repository files navigation

Welcome

This is a basic Next.js application that lets users log in using:

  • Credentials (email and password)
  • Google
  • GitHub

I've used MongoDB for storing the users and accounts. In the code, I've written lots of comments to make it easy to understand what each part does, helpful for anyone looking at it later.

This repository was based on: https://www.youtube.com/watch?v=PrdbyNYq-z4

What I used

Authentication: Next Auth

Toast notifications: react-hot-toast

Styling: TailwindCSS (I also used their sign in form component)

Understanding callbacks

When we use the credentials provider we have the following callbacks in the following order.

  1. Authorize function is called
  2. JWT callback func tion is called
  3. Session callback function is called

Misc things to remember

When you update your schema.prisma file, remember to stop your development server and run npx prisma generate

Extra features

On the `/login-google`` page, I've set up a Google login example that uses a popup. This method is great for keeping users on the same page, avoiding the typical redirect process.

It's a straightforward yet effective way to handle logins, ensuring users don't lose their current page context.

About

a small repository built to test out basic next auth features

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published