---
description: >-
  Learn how to allow users to create and edit user profiles, using Firebase for
  authentication and Airtable as the app backend.
---

# Create and edit user profile (Firebase + Airtable)



In this tutorial, we’ll use Firebase email-based authentication combined with post-login to create a user onboarding flow, where new users can add more information about them. Also, we’ll create a page where users can edit their profile information. We’ll use Airtable as our backend to store the user information.

You can follow this tutorial step by step to create the same use case we'll be showing, and you can also adapt it to your specific app.

## 🎨 Design file

In this tutorial, we’ll use the Figma file below, with all the tags required to implement the [Firebase email-based authentication](../../../integrations/user-authentication/app-login-firebase) and [post-login flow](../../../bravo-tags/intro-and-onboarding/post-login-page-onboarding). Feel free to duplicate it and customize it as you need, before importing it into Bravo to create a new app project. You can also import it as it is.

{% embed url="https://www.figma.com/community/file/1139917619983944012" %}

## 👥 Authentication setup (Firebase)

Before continuing with the tutorial, you’ll need to set up a Firebase project in order to use Firebase authentication. Follow [this guide](../../../integrations/user-authentication/app-login-firebase/email-password-login-firebase) to do that. You can skip the design section, since the necessary tags are already included in the design file we provided above.

As you’ll see, you’ll need to generate some files in Firebase and upload them to your Bravo app settings to enable Firebase authentication.

## 💾 Backend setup (Airtable)

We'll use [Airtable](https://www.airtable.com/) to store the user profile information. In case you haven't done that already, create a free account and a base to store the user information.

In this example, we created the following fields, which match the input fields for the forms where users can create and edit the profile information:

* Name (text field)
* Surname (text field)
* Age (numeric field)
* UserID (text field)
* Last Modified. We created this field to be able to sort the table by edit date and time. This is important in order to retrieve the correct user profile data later on.

You can duplicate the base below to get started:

```
https://airtable.com/appVmNCG1OLuQMiOe/shr1eL0nU7mEzguY3
```

## ⚙️ API collection setup

Once we have our design and backend ready, it's time to create all the API requests that are needed to connect our app and the backend. In case you haven't done so, import the [Bravorized](../../../set-up-design/setting-up-your-design-file) example design file (or your own file), with all the necessary Bravo tags, to create a new app project.

After creating your app project, create a new [API collection](../../../connect-api/set-up-api-requests/api-wizard-importer). You can use the Airtable wizard with your Airtable base, which will already generate a few API requests for you.&#x20;

{% hint style="info" %}
In case you use the wizard, note that you'll need to edit these requests and create new ones to match the ones we'll describe below. You can duplicate the ones created with the wizard, which will already contain the Airtable base URL and API key.
{% endhint %}

### Get User Profile - <mark style="color:green;">`GET`</mark>

We'll use this request to obtain the user profile data, by providing a [user ID](../../../../connect-api/request-url-variables#built-in-variables), filtering the Airtable base by this user ID (using [filterByFormula](https://support.airtable.com/hc/en-us/articles/223247187-How-to-sort-filter-or-retrieve-ordered-records-in-the-API)), and returning the data associated to that user. This is necessary in order to load values for the input fields in the page to edit the user profile, and allow the user to change them.

It's important that we also include the [Airtable view name](https://support.airtable.com/hc/en-us/articles/202624989-Views-overview), since this will keep the data records sorted in the same way as in the table (by latest modified). This is done to make the data management more robust: in case a user, for some reason, submits profile information under the same user ID more than once, we'll only use the latest data.

Replace `<BASE_ID>`, `<TABLE_NAME>` and `<VIEW_NAME>` with the corresponding values for your table.&#x20;

```
https://api.airtable.com/v0/<BASE_ID>/<TABLE_NAME>?filterByFormula={userID}=%22${user.id}%22&view=<VIEW_NAME>
```

To test the request, you'll need to use a test value for the ${user.id} variable. You can fill in a dummy value in your Airtable base, and reuse this value in the API request:

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2F1rit0IoQVedQm59wFcTq%2FCreate%20and%20edit%20user%20profiles%20\(Firebase%20%2B%20Airtable\).jpg?alt=media\&token=1709e3a2-339d-4967-852c-29d914f281ab)

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FnHZseI3sWdQlkDs3lXwC%2FCreate%20and%20edit%20user%20profiles%20\(Firebase%20%2B%20Airtable\)-1.jpg?alt=media\&token=5a2ba27a-65bc-4db2-a5a7-b0aa033480d1)

After testing the request successfully, select all the items related to the user profile. In this case, we don't want to create a list, but rather get the values for one specific user, which is one row in the Airtable base. Therefore, **it's very important that you select the 0 index in the dropdown for the .data.records path**. These data items will correspond with the latest profile information for the specific user ID we provided in the request - in case there's more than one row for that user ID, we'll always use the data for the "latest modified" one.

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FkDM4vHlKhsvAOM2jVoet%2FCreate%20and%20edit%20user%20profiles%20\(Firebase%20%2B%20Airtable\)-2.jpg?alt=media\&token=6a5e9fe5-a516-4b30-afe3-ca017643cc6a)

Finally, go to the "Output Variables" tab and set the following names for the data items you've selected. **It's very important that you set the name indicated below for the profile ID**, since we'll be using the same name in later steps and any misspelling will make the feature not to work properly.

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FhXWyfiwlqClQpIpl1XSq%2FCreate%20and%20edit%20user%20profiles%20\(Firebase%20%2B%20Airtable\)-13.jpg?alt=media\&token=7fbcd360-b7b7-4fad-9c4e-2746ef8a0948)

### Post User Profile - <mark style="color:blue;">`POST`</mark>

We'll use this request for the form where users can create a profile in the app onboarding. To do that, we'll use the following request URL and JSON body:

In the request URL, replace `<BASE_ID>` and `<TABLE_NAME>` with the corresponding values for your table.

```
https://api.airtable.com/v0/<BASE_ID>/<TABLE_NAME>
```

JSON body:

```
{
  "records": [
    {
      "fields": {
        "Name": "${name}",
        "Surname": "${surname}",
        "Age": ${age},
        "UserID": "${user.id}"
      }
    }
  ]
}
```

You can use some test values here as well to test the request. Since this is a POST request that we'll use to submit the user onboarding form, we don't need to select any data for binding - we'll only use the request to send data to Airtable.

### Edit User Profile - `PATCH`

Finally, we'll need a PATCH request to allow a user edit the profile information they submitted in the onboarding (for instance, change the name or the age). This PATCH request will target the specific row we obtained in the Get User Profile request, and change it with the new information the user submitted. We'll use the URL and JSON body indicated below for the request.

In the request URL, replace `<BASE_ID>` and `<TABLE_NAME>` with the corresponding values for your table.

```
https://api.airtable.com/v0/<BASE_ID>/<TABLE_NAME>
```

JSON body:

```
{
  "records": [
    {
      "id": "${profile_id}",
      "fields": {
        "Name": "${name}",
        "Surname": "${surname}",
        "Age": ${age}
      }
    }
  ]
}
```

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FL7MW9TpY2vwwURigcsFc%2FCreate%20and%20edit%20user%20profiles%20(Firebase%20%2B%20Airtable).jpg?alt=media&#x26;token=6d6d96cf-e4fd-4ca3-bdc2-bfa5eb60c487" alt=""><figcaption></figcaption></figure>

Note that we're using here a variable called `${profile_id}` as the record ID value. As you remember, we indicated the same name for the data item that returns the record ID in the [Get User Profile](#get-user-profile-get) request. These two names must match for the feature to work properly, since this is how Bravo knows which ID value to pass to the PATCH request, so it targets the correct table record.

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FhXWyfiwlqClQpIpl1XSq%2FCreate%20and%20edit%20user%20profiles%20\(Firebase%20%2B%20Airtable\)-13.jpg?alt=media\&token=7fbcd360-b7b7-4fad-9c4e-2746ef8a0948)

Now, you can use some test values to test this PATCH request. Make sure you indicate a valid profile\_id, you can get one from the Get User Profile request as shown below:

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FbOlHZipV0qaXRcPYi3Y9%2FCreate%20and%20edit%20user%20profiles%20\(Firebase%20%2B%20Airtable\)-3.jpg?alt=media\&token=32452241-5f71-4975-80fa-7c9404b60b62)

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FzexToVoR0s8rIH84LjQw%2FCreate%20and%20edit%20user%20profiles%20(Firebase%20%2B%20Airtable)-4.jpg?alt=media&#x26;token=f9504e0d-3bd5-4c52-aeda-bb88d85b159e" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Remember to set the headers of all the requests with the same Authorization!
{% endhint %}

## ⚒️ Data Binding setup

Once the API requests are created, it's time to bind them to the necessary app screens. We'll need to bind two screens:&#x20;

* The page where new users create a new profile in the onboarding&#x20;
* The page where existing users can edit the profile information they submitted in the onboarding.

### "user-profile" page

This is the screen created with the post-login functionality, where new users who register will navigate after registering with their email and password. The screen is called "user-profile" in our design example.

We'll bind the variables in the [Post User Profile](#post-user-profile-post) request to the form input fields in this screen, so a new record is created in Airtable with the new user profile. As you can see in the screenshot below, we'll bind the "Input Destination" property of the input fields to the corresponding variable.

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2Fpiif4AzPPq3i4yBr9LOY%2FCreate%20and%20edit%20user%20profiles%20\(Firebase%20%2B%20Airtable\)-5.jpg?alt=media\&token=02b53a6e-2f8d-4519-b687-a60c0a6a5880)

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FQcQkgCt9cBYAQaWY35Iu%2FCreate%20and%20edit%20user%20profiles%20(Firebase%20%2B%20Airtable)-6.jpg?alt=media&#x26;token=ddef085b-8eef-403d-822a-a22b360b6ee9" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2F90rsSi859mkPwbslDYrH%2FCreate%20and%20edit%20user%20profiles%20(Firebase%20%2B%20Airtable)-7.jpg?alt=media&#x26;token=7f534088-aff9-48f3-9b3a-83c37ce77a9f" alt=""><figcaption></figcaption></figure>

Finally, we'll make the users navigate to the "success" screen in case they created the user profile successfully, and show an error alert in case the API request was unsuccessful.

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FznHnGsJHAIMTT3UizqzI%2FCreate%20and%20edit%20user%20profiles%20\(Firebase%20%2B%20Airtable\)-12.jpg?alt=media\&token=a28ef969-5657-4378-99eb-a6256b67fe52)

### "edit-profile" page

In this page, we'll allow existing users to change their profile information.&#x20;

We'll bind the "Value" property of the input fields to the [Get user profile](#get-user-profile-get) request. This way, a user goes to this screen, they'll see the current profile data populate in the input fields. Then, they'll be able to edit as many fields as they wish.

Secondly, we'll bind the "Input Destination" property of the fields to the Edit user profile request. This way, when they submit the form, the new profile information will be sent to Airtable, and the corresponding table record will be updated with the information provided in the form. In case a user doesn't change all the fields, the information obtained with the "Value" property binding will be sent along - therefore, those data fields won't change.

![](https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FaX2oDFa8k88HSevME4Wk%2FCreate%20and%20edit%20user%20profiles%20\(Firebase%20%2B%20Airtable\).jpg?alt=media\&token=f643977d-fe94-40ac-bed9-4c6f0acd14c3)

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FkCyAHCi5A1oPzlqxedY3%2FCreate%20and%20edit%20user%20profiles%20(Firebase%20%2B%20Airtable)-1.jpg?alt=media&#x26;token=ea495a92-f56f-4e9b-b68d-6d15c559f45e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FhVr1lMUQm5jugJtMdg3f%2FCreate%20and%20edit%20user%20profiles%20(Firebase%20%2B%20Airtable)-2.jpg?alt=media&#x26;token=5de31ccd-b08b-4126-9d0b-cf817a792502" alt=""><figcaption></figcaption></figure>

Finally, we'll also set up an alert, so the user knows that the profile was edited successfully, or that an error happened.

<figure><img src="https://1444025092-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MXpqEanvOhm8vMtIH8i%2Fuploads%2FQSBNr2JKREHRAWlgsIQk%2FCreate%20and%20edit%20user%20profiles%20(Firebase%20%2B%20Airtable)-11.jpg?alt=media&#x26;token=01ba97ba-c323-4c56-9441-7611ef2237de" alt=""><figcaption></figcaption></figure>

## 📲 Test your app in [Bravo Vision](../../../good-to-know/faq/bravo-vision)!

That's it! The user profile feature is now ready to be used. Feel free to test the feature in Bravo Vision and to add it to your existing apps.&#x20;
