Guides & tutorials
LoginSign Up


Signup and auto login with Firebase and Arengu

Learn how to integrate Arengu with your own Firebase project, leveraging their user management APIs and creating a full authentication flow in a few steps.

Previous requirements

  • An existing Firebase project. If you don't have one, you can create one for free in the Firebase console.
  • An existing web app, where you'll be embedding the Arengu form.

1. Prepare your Firebase project

In the Firebase console for your project, enable the "Email/Password" sign-in provider in Build > Authentication > Sign-in method.

If you don't have an app registered in your project, go to the project settings (the cogwheel icon, next to "Project Overview"), in the "General" tab and register a new web app by clicking on the </> button.

Give it any name, and unless you are using it, don't enable the "Set up Firebase hosting for this app" checkbox, we won't be using that.

You'll be presented with a snippet of code. Save it somewhere as we'll be using later and click on "Continue to console".

Lastly, in the "Service accounts" tab and under "Firebase Admin SDK", click on the "Generate new private key" button. A JSON file will be downloaded, keep it for later!

2. Connect your Arengu account to your Firebase project

In Arengu, click on your profile button in the lower left corner and then on the "Vault" option.

Click on the "Add connection" button and choose "Firebase". Then, select the JSON file you downloaded from the Firebase console earlier, in the preparation step. The 3 fields will be automatically filled:

Click on "Continue" and give the connection a meaningful name. Finally, complete the connection with the "Add connection" button. Now you can use all the Firebase actions on your project from all Arengu flows.

3. Build the signup form

In the forms module, create a new form to your liking. We'll be needing only one step, containing at least:

An email field:

  • ID: 'email'
  • Required: enable this checkbox to make it mandatory

A password field:

  • ID: 'password'
  • Required: enable this checkbox to make it mandatory
  • Min. length: Firebase requires the passwords to be at least 6 characters, so it's a good idea to enforce it here instead of failing later in a less user-friendly way.

A Next button.

4. Add form logic with a flow

Now we need to build some logic to handle the data the user will submit in the form and generate the token Firebase needs to actually log the user in.

Add a new next step flow to the form we just created and set it up this way:

Tryin to get a user with that email

This action tries to get the user from the database of your Firebase project, using the email that the user entered in the form. Set it up like this:

  • ID: 'firebaseLookup'
  • Field: Email
  • Value: {{}}

Checking the result of the lookup

If the previous lookup was successful (i.e. its result had a value), that means that email was already registered and we'll stop with an error message. We can check this with an if/then condition configured this way:

  • Condition: {{firebaseLookup.body.user}} and "has value"

Creating the user

If the user does not exist, create the user in Firebase with the sign up action, using the email and password from our form. Configure the 'Sign up' action with these settings:

  • ID: 'firebaseSignup'
  • Enable the 'Set email' checkbox
  • Email: {{}}
  • Password: {{input.body.password}}

What about the 'Mark email as verified' checkbox? Note that — because we want to keep this tutorial short — we're skipping a very important step, which is verifying that the email address actually exists. But don't worry, you can do that easily in Arengu too. Just head over to our guide about email OTP flows.

Requesting a secure token for logging in

The sign up action returned a unique random identifier for the user we just created. We'll be using that in the 'Issue a token' action, so Firebase gives us back a secure token that we will use to actually log in the user.

Set the action up like this:

  • ID: 'issueAToken'
  • Local ID: reference the {{firebaseSignup.body.localId}} from the outputs of the previous action after an execution of the flow.

Making the secure token available to the form

The previous action returned a secure token that we have to make available in the ending screen of the form.

In order to do that, use the ‘Store state variable’ action configured this way:

  • Data fields: set an item with name token and reference the {{issueAToken.token}} variable from the outputs of the previous action.

Finally include a ‘Submit the form’ action, which does not need to be configured, and publish the changes.

5. Configure the ending screen

Go back to the form editor in Arengu, open the form and click on the ending screen. Enable the ‘User session’ option and configure it as follows:

  • Provider: select Firebase.
  • Token: reference the {{state.token}} from the flow.

You can also configure the redirection URL, a thank you message to display in the form, and a JS callback. Once everything is set up, publish the changes and click on the Preview button to test it.

When logging in the user, our SDK assumes that the Firebase SDK has been already initialized. Make sure you do it or both your application and the form will not work properly.

6. Embed the form into your web app

Click on the 'Embed' tab at the top of the editor, choose the type of web app you're integrating Arengu with, and follow the instructions there. They are most often just copying a couple of lines of HTML.

Remember that Firebase, when a user logs in, attaches the session to the current host, so your form has to be embedded in the same host as your application.

Table of contents