The example repository is maintained from a monorepo. Pull Requests should be opened against
nextauthjs/next-auth
.
Open Source. Full Stack. Own Your Data.
NextAuth.js is a complete open-source authentication solution.
Go to next-auth.js.org for more information and documentation.
The base project this was shamelessly stolen from https://github.com/nextauthjs/next-auth-example
git clone git@github.com:tiongg/sgid-next-auth.git
cd next-auth-sgid
pnpm i
Copy the .env.local.example file in this directory to .env.local (which will be ignored by Git):
cp .env.local.example .env.local
Add details for one or more providers (e.g. Google, Twitter, GitHub, Email, etc).
A database is needed to persist user accounts and to support email sign in. However, you can still use NextAuth.js for authentication without a database by using OAuth for authentication. If you do not specify a database, JSON Web Tokens will be enabled by default.
You can skip configuring a database and come back to it later if you want.
For more information about setting up a database, please check out the following links:
-
Review and update SgidProvider options in
pages/api/auth/[...nextauth].js
as needed. -
When setting up sgid, configure the callback URL to
{server}/api/auth/callback/sgid
in the sgid dev portal
e.g. http://localhost:3000/api/auth/callback/sgid
To run your site locally, use:
pnpm run dev
-
Copy
pages/api/providers/sgid.provider.ts
and paste it into your app -
Configure profile as needed
https://github.com/nextauthjs/next-auth-example: The base template
https://github.com/opengovsg/sgid-client: Sgid Client