onCreate イベントと onDelete イベントは、作成または削除されたユーザーに関する情報を含む User オブジェクトと EventContext オブジェクトを提供します。次に例を示します。
Node.js
exports.myFunction=functions.auth.user().onCreate((user,context)=>{constemail=user.email;// The email of the user.constdisplayName=user.displayName;// The display name of the user.});
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[],[],null,["# Customizing the authentication flow using asynchronous functions\n================================================================\n\nThis document shows you how to extend Identity Platform authentication\nusing asynchronous [Cloud Run functions](/functions).\n\nAsynchronous functions let you trigger non-blocking tasks in response to user\ncreation and deletion. They are useful for starting long-running operations or\nperforming auxiliary tasks, like sending a welcome email.\n\nTo directly modify the result of an authentication operation, see\n[Extending authentication with blocking functions](/identity-platform/docs/blocking-functions).\nThe user object that an asynchronous function receives does not contain\nupdates from the blocking function.\n\nBefore you begin\n----------------\n\nCreate an app with Identity Platform. See the\n[Quickstart](/identity-platform/docs/quickstart-email-password) to learn how.\n\nCreating an asynchronous function\n---------------------------------\n\nTo create and deploy an asynchronous function, follow the steps in\n[Get started: write, test, and deploy your first functions](https://firebase.google.com/docs/functions/get-started).\n\nResponding to user creation\n---------------------------\n\nThe `onCreate` event triggers whenever a user account is created. This includes\nanonymous sessions and accounts created with the Admin SDK. The function does\nnot trigger when a user signs in for the first time using a custom token.\n\nThe following example shows how to register a handler for `onCreate`: \n\n### Node.js\n\n exports.myFunction = functions.auth.user().onCreate((user) =\u003e {\n // TODO.\n });\n\nResponding to user deletion\n---------------------------\n\nThe `onDelete` event triggers whenever a user account is deleted. The following\nexample shows how to register a handler for `onDelete`: \n\n### Node.js\n\n exports.myFunction = functions.auth.user().onDelete((user) =\u003e {\n // TODO.\n });\n\nGetting user information\n------------------------\n\nThe `onCreate` and `onDelete` events provide `User` and `EventContext` objects\nthat contain information about the created or deleted user. For example: \n\n### Node.js\n\n exports.myFunction = functions.auth.user().onCreate((user, context) =\u003e {\n const email = user.email; // The email of the user.\n const displayName = user.displayName; // The display name of the user.\n });\n\nSee the\n[`UserRecord` API reference](https://firebase.google.com/docs/reference/admin/node/firebase-admin.auth.userrecord)\nand the\n[`EventContext` API reference](https://firebase.google.com/docs/reference/functions/firebase-functions.eventcontext)\nfor a list of available fields.\n\nWhat's next\n-----------\n\n- Extend authentication with [blocking functions](/identity-platform/docs/blocking-functions).\n- Learn more about [Cloud Run functions](/functions/docs)."]]