You can trigger a Cloud Function in response to the creation and deletion of user accounts via Firebase Authentication. For example, you could send a welcome email to a user who has just created an account in your app. Examples in this page are based on a sample that does exactly this — sends welcome and farewell emails on user creation and deletion.
For more examples of use cases, see What can I do with Functions?
Trigger a function on user creation
You can create a Cloud Function that triggers when a Firebase user is
created using the
Firebase accounts can be created in the following events:
- A user creates an email and password account
- A user signs in for the first time using a federated identity Provider
- A user signs in to a new anonymous auth session for the first time
- A user signs in for the first time using a custom token
- The developer creates an account using the Firebase Admin SDK
Access user attributes
Trigger a function on user deletion
Just as you can trigger a Cloud Function on user creation, you can
respond to user deletion events. Use the
event handler as shown: