This is a Next.js project bootstrapped with create-next-app
.
Authentication package is next-auth
.
Netlify live demo: https://ubiquitous-souffle-96df03.netlify.app/signin
Clone the repo:
git clone
Install dependencies:
npm install
Create .env.local
file:
In order to use the local test user, you will need to:
- Create a new file,
.env.local
in the root directory of the project on your local machine (it will be ignored by git). - Run this command in your terminal (this generates a token for your app to use locally to decode the JWT it generates):
openssl rand -base64 32
- Add the following values to
.env.local
:
NEXTAUTH_SECRET = your-generated-token-from-the-command-above
NEXTAUTH_URL = http://localhost:3000
- To use the Google login option locally: Sign up for Google Cloud console account
and generate the tokens below per the directions there. - Add them in
.env.local
as shown:
GOOGLE_CLIENT_ID = your-google-client-id
GOOGLE_CLIENT_SECRET = your-google-client-secret
Start the dev server:
npm run dev
Open http://localhost:3000/signin with your browser to see the result.
NOTE: There is currently only a single user that can be authenticated with email/password; use this user to test:
Email: jsmith@email.com
Password: test12345
You will need a gmail account to use the Login with Google feature.
Once logged in, you will be taken to the /me page, a basic page showing your session details.
Once signed out, you will be redirected to the /signin page.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.