Learn how to install Firebase Extensions
At the last Firebase Developer Summit, the Firebase team announced several new features. One that you’ll enjoy a lot is Firebase Extensions.
Their website defines them as:
Designed to increase productivity, Firebase Extensions provide extended functionality to your apps without the need to research, write, or debug code on your own.
This just means that they noticed some functionality most of their users were implementing on their own and decided to implement it for you, so you can just click install and run it in your app.
Best way to understand this is to see it in action. Today we’re going to install an extension called Delete User Data.
What Delete User Data does is create a function that if you remove a user from Firebase Authentication, all the data linked to them (From Firestore, the RTDB, or Storage) gets also deleted.
So for example, every time you delete a user from your app that package can automatically delete their user profile from the database and all the files they have on your storage bucket.
Installing the Delete User Data extension
To install this extension you need to go to the Firebase Extensions Page, scroll down and look for it.
Don’t click on install just yet. Click on the name of the function so that you can go to its detail page and read more about how it works.
In that page you can read more about it, and see what it changes, what kind of permissions it needs, what resources it creates for you, etc.
Now go ahead and click on install, you’ll be prompted to choose the Firebase project where you want to install the extension.
Once you select the project you’ll get 3-step configuration form:
That form is going to first show you what the package needs to install, on our case, it needs to create one cloud function in our project.
Then, it shows you the kind of access it has, this to be able to delete the data.
And lastly, it tells you to configure it. I keep my user’s profiles under the users
collection, then use the users
uid
as the document’s ID.
That’s why you see that I typed users/{UID}
in the Firestore path input. If you have user data somewhere else, you can
add it separated by commas. For example, if you add something like this:
users/{UID},teamMembers/{UID}
It will go into the user’s collection and into the teamMember’s collection looking for that user’s UID and then delete that document.
Go ahead and click install, you’ll see a progress bar of the extension installing itself into your project.
Once it’s done, it will show up as installed
And if you click on get started, you’ll go to the extension’s detail page where you can edit it, change anything, or straight up delete it.
Do let me know if you plan on using it, or if there’s something else you’d like them to build :)