Authentication
Last updated
Was this helpful?
Last updated
Was this helpful?
Shipped supports and Supabase to handle user authentication.
With NexAuth you can create two types of authentications, Magic Links and Social Authentication which includes using Google, Twitter, Facebook, LinkedIn, Slack, and 60+ more services to sign up your users.
With Supabase Auth you get Magic Link Auth, Email and Password Auth, and Social Authentication.
If you intend to use Supabase, follow , for NextAuth continue reading.
The authentication logic resides in src/config/auth.ts
.
In that file, you define the authentication providers to use.
Shipped provides Sign-Up (/signup) and Login (/login) pages out of the box. Feel free to customize them according to your needs.
Add this to your .env
file:
Magic Link Auth is a mechanism that sends an email to the user whenever they want to sign up or log into your product. You define for how long the link will be valid (24 hours or more).
To use this authentication method, you need an email SMTP server.
Add this provider to the NextAuth configuration (src/config/auth.ts
).
Remember to configure the environment variables MAILPACE_EMAIL_SERVER
and EMAIL_FROM
into the .env
and Environment settings of your hosting service.
Google Sign-Up is one of the most popular authentication methods.
To enable it you need to:
Go to APIS & Services then Credentials
Click on Configure Consent Screen
Fill in all the info.
Add userinfo.email
and userinfo.profile
to scope
Submit
Go to Credentials and click "Create Credentials", then "OAuth Client ID"
Select "Web Application"
Add http://localhost:3000 and https://yoursitename.com into the Authorized JavaScript Origins.
Add http://localhost:3000/api/auth/callback/google and https://yoursitename.com/api/auth/callback/google to Authorized redirect URLs.
Click Submit
Copy and paste the Client ID and Client Secret into the .env
file:
Go to "OAuth Consent Screen" and click "Publish App".
Open src/config/auth.ts
and add this provider
NextAuth supports 60+ authentication providers.
Some examples:
Atlassian
Twitter / X
Apple
Amazon Cognito
Discord
GitHub
GitLab
Medium
Salesforce
Spotify
Twitch
Zoom
You can generate a secret using the .
Authentication needs a database to store the user's authentication information. if you haven't already.
I use to send transactional emails, and they provide an SMTP server as well.
But you can use , , , , or any other email provider.
Create a new project on
Google might request you to verify your domain in . It requires you to configure a CNAME or TXT DNS record.
Check the to learn how to integrate other third-party sign-in methods.