• Blog
  • Documentation
  • Courses
  • Changelog
  • AI Starters
  • UI Kit
  • FAQ
  • Supamode
    New
  • Pricing

Launch your next SaaS in record time with Makerkit, a React SaaS Boilerplate for Next.js and Supabase.

Makerkit is a product of Makerkit Pte Ltd (registered in the Republic of Singapore)Company Registration No: 202407149CFor support or inquiries, please contact us

About
  • FAQ
  • Contact
  • Verify your Discord
  • Consultation
  • Open Source
  • Become an Affiliate
Product
  • Documentation
  • Blog
  • Changelog
  • UI Blocks
  • Figma UI Kit
  • AI SaaS Starters
License
  • Activate License
  • Upgrade License
  • Invite Member
Legal
  • Terms of License
    • Adding API Routes
    • Change Authentication strategy
    • Fetching the signed in User
    • Reading a Document
    • Creating a Document
    • Configuring Plans
    • Project Configuration
    • Updating the Navigation menu
    • Adding a new translation string
    • Guarding an API Route
    • Adding Pages
    • Updating the Sidebar menu
    • Require Email Verification
    • Fetching the selected Organization
    • Reading a list of Documents
    • Updating a Document
    • Running the Stripe Webhook locally
    • Branding
    • Setting a Default Language
    • Dark Theme
    • Theming
    • Calling API Routes from the client
    • Deleting a Document
    • Updating the Logo
    • Adding a new language in the Next.js Firebase SaaS Kit
    • Checking CSRF Tokens
    • Passing data from server to client
    • Updating the Fonts
    • Adding Pages
    • Guarding Pages
    • Using Lemon Squeezy instead of Stripe
    • Updating the Favicons
    • Using the Language Switcher
    • Environment variables
    • Detect current Locale
    • Setting up Emails

How to change Authentication strategy | Next.js Firebase SaaS Kit

Learn how to change the authentication strategy in Makerkit. Choose between email and password, phone number, email link, and OAuth.

Makerkit supports various authentication strategies supported by Firebase. We can customize these using the global configuration at src/configurationt.ts.

In the configuration file, you can find the following code:

ts
auth: {
// Enable MFA. You must upgrade to GCP Identity Platform to use it.
// see: https://cloud.google.com/identity-platform/docs/product-comparison
enableMultiFactorAuth: true,
// When enabled, users will be required to verify their email address
// before being able to access the app
requireEmailVerification:
process.env.NEXT_PUBLIC_REQUIRE_EMAIL_VERIFICATION === 'true',
// NB: Enable the providers below in the Firebase Console
// in your production project
providers: {
emailPassword: true,
phoneNumber: false,
emailLink: false,
oAuth: [GoogleAuthProvider],
},
},

We will need to edit this file to change the authentication strategy.

Enabling Email and Password Authentication

This is the default authentication strategy. It allows users to sign up and sign in using their email and password.

To enable this strategy, set providers.emailPassword to true.

tsx
providers: {
emailPassword: false,
phoneNumber: true,
emailLink: false,
oAuth: [GoogleAuthProvider],
},

Enabling Phone Number Authentication

This strategy allows users to sign up and sign in using their phone number.

To enable this strategy, set providers.phoneNumber to true.

tsx
providers: {
emailPassword: false,
phoneNumber: true,
emailLink: false,
oAuth: [GoogleAuthProvider],
},

Enabling Email Link Authentication

This strategy allows users to sign up and sign in using their email address. A link will be sent to their email address to verify their identity.

To enable this strategy, set providers.emailLink to true.

tsx
providers: {
emailPassword: false,
phoneNumber: trfalseue,
emailLink: true,
oAuth: [GoogleAuthProvider],
},

Enabling OAuth Authentication

This strategy allows users to sign up and sign in using their social media accounts. You can enable multiple OAuth providers.

To enable this strategy, set providers.oAuth to an array of OAuth providers.

tsx
import { GoogleAuthProvider, FacebookAuthProvider } from 'firebase/auth';
providers: {
emailPassword: false,
phoneNumber: false,
emailLink: false,
oAuth: [GoogleAuthProvider, FacebookAuthProvider],
},

Can I use multiple authentication strategies?

Yes, you can use multiple authentication strategies. For example, you can enable email and password authentication and phone number authentication at the same time.

tsx
providers: {
emailPassword: true,
phoneNumber: true,
emailLink: false,
oAuth: [GoogleAuthProvider],
},

With that said, the UI is not designed to support multiple authentication strategies. You will need to customize the UI to support multiple authentication strategies*.

On this page
  1. Can I use multiple authentication strategies?