Clerk logo

Clerk Docs

Ctrl + K
Go to


Learn how to integrate Clerk into your Next.js + Firebase application

Getting Started

To enable the integration, you will need to provide Clerk with the required Firebase configuration attributes depending on the Firebase features you would require authenticated user access to.

To get started, turn on the Firebase integration in the Clerk Dashboard:

Your Application & instance → Integrations → Firebase

Check out our example application showcasing how to integrate Clerk with Firebase:

Integration configuration

To allow Clerk to generate the required authentication token for Firebase, you will need to set some configuration attributes on the Clerk integration page.

1. (Easy way) Upload a JSON Firebase configuration file

You can upload the JSON configuration file you will retrieve from Firebase directly on the integrations page and the required fields will be filled in automatically.

  • To get the Firebase JSON configuration file, navigate to your Project Settings  Service Accounts → Firebase Admin SDK and then click the Generate new private key button.
  • To upload the file on Clerk, use the Upload JSON button on the Firebase integration screen inside the configuration modal:

2. Fill in the required attributes manually

The attributes that you need to fill in to connect Clerk with Firebase, as a custom authentication system, are described below:

  • Service account ID The service account ID can be found in the Google Cloud Console for your Firebase project, or in the client_email field of a service account JSON file.
  • Project ID The Firebase project ID is the unique identifier of your Firebase project. Can be found under the Project Settings in the Firebase platform.
  • Database URL (Optional)The Firebase Realtime Database URL as retrieved from the Firebase platform under the Realtime Database page.
  • Private Key The private key used for signing which belongs to the Google service account ID of your project. Can be found in the Google Cloud Console for your Firebase project, or in the private_key field of a service account JSON file.

Firebase user sign-in with Clerk as an authentication provider

After successfully completing the integration setup on your dashboard, you should setup your frontend to connect Clerk with the Firebase authentication system.

1. Retrieve a Firebase user authentication token from Clerk

The Firebase Web SDK requires an authentication token to sign in your users using Clerk as the custom authentication provider. This token can be retrieved calling the getToken method returned from the useAuth() hook and calling it with the "integration_firebase" template parameter.


The above method will return the token needed for the Firebase Web SDK to sign in your users with Clerk.

2. Sign-in using the Firebase Web SDK

The Firebase Web SDK referenced is the browser installation of the official Firebase JavaScript SDK package on npm.

To authenticate your users on Firebase using Clerk you would need to call the signInWithCustomToken method of the Firebase Auth scope.


An example implementation using Next.js:


Was this helpful?

Clerk © 2022