Switch from Firebase auth to Supabase auth, the open-source Firebase alternative

Mika S.
2 min readFeb 11, 2021

--

If you’re using Firebase as a authentication service for your application and you’re considering moving over to Supabase, the open-source alternative, this guide helps you walk through the migration.

This guide assumes you’re already familiar with Firebase and basic concepts of it. To begin with, we will need to retrieve few resources:

Anon public key. This can be found under your Supabase project’s settings, under the API section.

Database URL. This can be found on the same page as your anon public key.

Supabase JavaScript client. You will need the latest version of JavaScript client for Supabase. You can install it with npm:

npm install @supabase/supabase-js

Then import it to your application in place of your `firebase.initializeApp(firebaseConfig);`

import { createClient } from ‘@supabase/supabase-js’

// Create a single supabase client for interacting with your database const supabase = createClient(‘https://xyzcompany.supabase.co’, ‘public-anon-key’)

👏 Now you’ve added Supabase to your application!

Authentication in Supabase vs Firebase

Here is a breakdown of how authentication functions differ between the two services.

Create new users

Create new users with Firebase
Create new users with Supabase

Log in to existing user

Log in to existing user with Firebase
Log in to existing user with Supabase

Get the current user

Receive a notification every time an auth event happens

Listen to auth state changes in Firebase
Listen to auth state changes in Supabase

That’s it! Now you’ve migrated from Firebase authentication to Supabase.

For further reading, you can refer to Supabase.io/docs

Thank you!

--

--

Mika S.
Mika S.

Written by Mika S.

I build complex things on the web and share my findings to help others learn too.

Responses (2)