Next Auth

Configure next-auth with a single click

Usage

npx next-inject add next-auth

Setup Environment

Google

  1. Start by creating a google cloud project here.
  2. In the search bar, search credentials and select the option related to APIs and services.
  3. Press Create Credentials and create an OAuth client ID.
  4. Set the Authorized JavaScript origins and Authorized redirect URIs as follows:
  1. Copy the Client ID and Client Secret into the .env.local file at the root of your Next.js project as follows:
# NOTE: you must use this exact naming convention, these
# are simply new conventions for the new Auth.js version.
# https://authjs.dev/reference/nextjs#environment-variable-inference
 
AUTH_GOOGLE_ID=YOUR_GOOGLE_ID
AUTH_GOOGLE_SECRET=YOUR_GOOGLE_SECRET

Github

  1. Visit this link to create an OAuth app.
  2. Rotate between the following Homepage URLs and Authorization callback URLs:

Make sure to use localhost for testing, and switch to your production URL when deploying your code.

  1. Copy your Client ID, then generate a Client secret and copy that too.
  2. Paste your credentials into your .env.local file as follows:
# NOTE: you must use this exact naming convention, these
# are simply new conventions for the new Auth.js version.
# https://authjs.dev/reference/nextjs#environment-variable-inference
 
AUTH_GITHUB_ID=YOUR_GITHUB_ID
AUTH_GITHUB_SECRET=YOUR_GITHUB_SECRET
Bonus Features
Google and Github OAuth configured
Beautiful login form
Beautiful login modal
Syncs perfectly with our database plugins
Demo authentication button to login and logout instantly

Any further questions?
Please do not hesitate to contact us by email or twitter
Also, If you are enjoying Next Inject, feel free to share a testimonial here!

On this page