拡張機能のパブリッシャーの概要
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Firebase Extension は、HTTP リクエストに応答して、または Firebase と Google の他のプロダクト(Firebase Cloud Messaging、Cloud Firestore、Pub/Sub など)からのイベントをトリガーして、特定のタスクまたは一連のタスクを実行します。
個人的に利用する拡張機能を作成することも、Firebase Extensions Hub で世界中のユーザーと共有することもできます。たとえば、アプリで定期的に必要となる特定のタスクを実行したり、会社の API に簡単にアクセスする拡張機能を作成できます。作成した拡張機能は他のユーザーと共有できます。これらのユーザーは、自分の Firebase プロジェクトで使用する拡張機能をインストールして構成できます。
拡張機能の構造
拡張機能は、次の 3 つの主要コンポーネントで構成されます。
- Cloud Functions の関数のコード(JavaScript または TypeScript)
- 拡張機能を説明するメタデータ
- ユーザーが拡張機能を構成して使用する際に役立つドキュメント
拡張機能を開発するには、これらのコンポーネントを次の構造にアセンブルします。
example-extension
├── functions
│ ├── integration-tests
│ │ ├── extensions
│ │ │ └── example-extension.env
│ │ ├── firebase.json
│ │ └── integration-test.spec.js
│ ├── index.js
│ └── package.json
├── README.md
├── PREINSTALL.md
├── POSTINSTALL.md
├── CHANGELOG.md
├── icon.png
└── extension.yaml
functions
ディレクトリには、Cloud Functions の関数のコード(JavaScript または TypeScript)を含めます。これは、Firebase と Google サービスによってトリガーされたイベントに応答して拡張機能のタスクを実行するコードです。
extension.yaml
ファイルには、トリガーや IAM アクセスロールなど、拡張機能に関するメタデータと、ユーザーが構成できるパラメータを含めます。
PREINSTALL
、POSTINSTALL
、CHANGELOG
ファイルは、拡張機能に必要な最小限のドキュメントです。これらのファイルは、拡張機能が実行する処理、使い方、更新内容を知るのに役立ちます。また、ユーザーが拡張機能を認識できるように、アイコンを用意する必要があります。ユーザーが拡張機能を検索、インストール、管理するときに、これらのファイルの内容が Firebase コンソール、Firebase CLI、Extensions Hub に表示されます。
拡張機能を作成したら、Firebase CLI を使用してプロジェクトにインストールしたり、Extensions Hub に公開できます。Extension Hub では、この拡張機能をプロジェクトに追加してインストールできます。
拡張機能で利用できるプロダクト
Firebase Extensions は Cloud Functions を使用して動作するため、どのような統合が可能かという質問には、拡張機能の関数をどのプロダクトでトリガーできるのかという意味と、トリガー後にどのプロダクトが拡張機能の関数と連携できるのかという意味があります。
サポートされている関数トリガー
手動トリガー
関数のトリガーは手動で行うことができます。Firebase Extensions と Cloud Functions では、次の 2 つの方法で関数を手動でトリガーします。
- HTTP トリガー: HTTP エンドポイントに関数をデプロイします。
- 呼び出し可能関数: Firebase クライアント SDK を使用して、iOS、Android、またはウェブ クライアント コードから直接 Cloud Functions を呼び出します。
拡張機能から HTTP エンドポイントを公開することで、Webhook をサポートする任意のウェブサービスと統合できます。呼び出し可能関数を使用すると、拡張機能をインストールするユーザーは Firebase SDK をクライアント ライブラリとして使用し、拡張機能で実装されている API にアクセスできます。
Firebase サービスのトリガー
ほとんどの Firebase プロダクトは、拡張機能の Cloud Functions の関数をトリガーできるイベントを出力します。
- アナリティクス: アナリティクスがイベントを記録したときに関数をトリガーします。
- App Distribution: App Distribution がアラートをトリガーしたときに関数をトリガーします。
- Authentication: ユーザーがアカウントを作成または削除したときに関数をトリガーします。
- Cloud Firestore: ページの作成、更新、削除時に関数をトリガーします。
- Cloud Storage: バケットでオブジェクトのアップロード、アーカイブ、削除が実行されたときに関数をトリガーします。
- Crashlytics: Crashlytics がアラートをトリガーしたときに関数をトリガーします。
- Performance Monitoring: Performance Monitoring がアラートをトリガーしたときに関数をトリガーします。
- Realtime Database: データの作成、更新、削除時に関数をトリガーします。
- Remote Config: パラメータが更新されたときに関数をトリガーします。
- Test Lab: Test Lab がアラートをトリガーしたときに関数をトリガーします。
Google Cloud サービスのトリガー
拡張機能では、Firebase 以外の Google Cloud サービスをトリガーする関数も使用できます。
- Cloud Pub/Sub: 構成可能な Pub/Sub トピックにイベントが投稿されたときにトリガーされる関数を拡張機能に含めることができます。
- Cloud Scheduler: 設定されたスケジュールで実行される関数を拡張機能に含めることができます。
- Cloud Tasks: Cloud Tasks を使用してキューに追加できる関数を拡張機能に含めることができます。Firebase Extensions で、拡張機能の作成者は拡張機能のライフサイクル イベント(プロジェクトへの初回インストール、新しいバージョンへのアップグレード、バージョンの再構成)に応答する関数を作成できます。
- Eventarc: 構成可能な Eventarc チャネルにイベントが公開されるとトリガーされる関数を拡張機能に含めることができます。また、拡張機能が Eventarc チャネルに独自のイベントを公開することで、ユーザーは拡張機能のイベントからトリガーする独自の関数を定義できます。
関数からのサポート
拡張機能の Cloud Functions の関数がトリガーされると、考えられる統合の範囲は一般にオープンエンドになります。以下では、Cloud Functions の関数でできることをいくつか紹介します。
- サポートされている IAM ロールを使用する Firebase または Google Cloud サービスに対する読み取り、書き込み、その他の操作。
- ウェブ API を提供するサードパーティ サービスの利用。
- カスタム サービスとの連携(ウェブ API を提供する場合)。
- TensorFlow.js、Express.js などの JavaScript ライブラリの実行。
拡張機能の作成方法
スタートガイドのチュートリアルでは、完全な拡張機能の作成、テスト、公開のプロセスについて説明しています。これは、拡張機能の作成方法を学習するためのおすすめの方法です。
始める
スタートガイドをひととおり確認したら、トピックごとのガイドに進みます。このガイドでは、独自の拡張機能の作成に関する次のタスクについて説明しています。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-12 UTC。
[null,null,["最終更新日 2025-08-12 UTC。"],[],[],null,["\u003cbr /\u003e\n\nA Firebase Extension performs a specific task or set of tasks in response to\nHTTP requests or triggering events from other Firebase and Google products, like\nFirebase Cloud Messaging, Cloud Firestore, or Pub/Sub.\n\nYou can build your own extension for personal use or to share with the world in\nthe Firebase Extensions Hub. For example, your extension can perform a specific\ntask that your app regularly needs, or it can make it easier to access one of\nyour company's APIs. After you build your extension, you can share it with\nothers. Those users can install and configure the extension for use in their own\nFirebase projects.\n\nStructure of an extension\n\nYou can think of an extension as having three main components:\n\n- Cloud Functions code, in JavaScript or TypeScript\n- Metadata that describes your extension\n- Documentation to help your users configure and use your extension\n\nTo develop an extension, you assemble these components into the following\nstructure: \n\n example-extension\n ├── functions\n │ ├── integration-tests\n │ │ ├── extensions\n │ │ │ └── example-extension.env\n │ │ ├── firebase.json\n │ │ └── integration-test.spec.js\n │ ├── index.js\n │ └── package.json\n ├── README.md\n ├── PREINSTALL.md\n ├── POSTINSTALL.md\n ├── CHANGELOG.md\n ├── icon.png\n └── extension.yaml\n\n- The `functions` directory contains your Cloud Functions code in JavaScript or TypeScript. This is the code that performs the extension's tasks in response to events triggered by Firebase and Google services.\n- The `extension.yaml` file contains metadata about your extension, such as its triggers and IAM access roles, as well as any parameters you want to be user-configurable.\n- The `PREINSTALL`, `POSTINSTALL`, and `CHANGELOG` files are the minimum documentation your extension must have. These files help your users learn what your extension does, how to use it, and what updates you've made. You should also provide an icon to help users recognize your extension. The Firebase console, Firebase CLI, and Extensions Hub display the contents of these files when users explore, install, and manage your extension.\n\nAfter you have created your extension, you can use the Firebase CLI to install\nit into a project or publish it to the Extensions Hub, where anyone can discover\nand install it into their projects.\n\nWhat products can my extension interact with?\n\nBecause a Firebase extension does its work using Cloud Functions, you can think\nof the question of possible integrations in two ways: *What products can trigger\nmy extension's functions?* and *Once triggered, what products can my extension's\nfunctions interact with?*\n\nSupported function triggers\n\nManual triggers\n\nFirst of all, you can manually trigger a function. Firebase Extensions and Cloud\nFunctions support two ways of manually triggering functions:\n\n- HTTP triggers: deploy a function to an HTTP endpoint\n- Callable functions: call your Cloud Functions directly from your iOS, Android, or web client code, using the Firebase client SDKs.\n\nBy exposing HTTP endpoints from your extension, your extension can potentially\nintegrate with any web service that supports webhooks. With callable functions,\nusers who install your extension can use the Firebase SDKs as a client library\nfor accessing the API your extension implements.\n\nFirebase service triggers\n\nMost Firebase products emit events that can trigger an extension's Cloud\nFunctions.\n\n- **Analytics:** trigger functions when Analytics logs an event\n- **App Distribution:** trigger functions when App Distribution triggers an alert\n- **Authentication:** trigger functions when users create and delete accounts\n- **Cloud Firestore:** trigger functions when pages are created, updated, or deleted\n- **Cloud Storage**: trigger functions when objects are uploaded, archived, or deleted from buckets\n- **Crashlytics:** trigger functions when Crashlytics triggers an alert\n- **Performance Monitoring:** trigger functions when Performance Monitoring triggers an alert\n- **Realtime Database:** trigger functions when data is created, updated, or deleted\n- **Remote Config:** trigger functions when a parameter is updated\n- **Test Lab:** trigger functions when Test Lab triggers an alert\n\nGoogle Cloud service triggers\n\nAn extension can also include functions that trigger off several non-Firebase\nGoogle Cloud services:\n\n- **Cloud Pub/Sub**: an extension can include functions that trigger when events are posted to a configurable Pub/Sub topic.\n- **Cloud Scheduler**: an extension can include functions that run on a set schedule\n- **Cloud Tasks**: an extension can include functions that can be queued using Cloud Tasks. Firebase Extensions uses this capability to let you, as an extension author, write functions that respond to an extension's \"lifecycle\" events: being installed in a project for the first time, being upgraded to a new version, and being reconfigured.\n- **Eventarc** : an extension can include functions that trigger when events are published to a configurable Eventarc channel; conversely, an extension can publish its own events to an Eventarc channel in order to enable users to define their own functions that trigger from an *extension's* events.\n\nSupported from functions\n\nOnce an extension's Cloud Function has been triggered, the range of possible\nintegrations is generally open ended. Here are some highlights of what you can\ndo from a Cloud Function:\n\n- Read, write, and otherwise interact with any **Firebase** or **Google Cloud** service that uses a [supported IAM role](/docs/extensions/publishers/access#supported-roles).\n- Work with any **third-party service** that provides a web API.\n- Work with your **custom services** if you provide a web API.\n- Run most JavaScript libraries, including **TensorFlow.js** , **Express.js,** and so on.\n\nHow to build an extension\n\nThe [Get Started](/docs/extensions/publishers/get-started) tutorial walks you through\nthe process of building, testing, and publishing a complete extension, and is\nthe recommended way to learn how to build one.\n\n[Get Started](/docs/extensions/publishers/get-started)\n\nAfter you've gone through the getting started guide once, you can refer to the\nindividual topic guides, which explain each of the tasks involved in building\nyour own extension:\n\n- [Write functions for an extension](/docs/extensions/publishers/functions)\n- [Use parameters in an extension](/docs/extensions/publishers/parameters)\n- [Set up appropriate access for an extension](/docs/extensions/publishers/access)\n- [Respond to extension lifecycle events](/docs/extensions/publishers/lifecycle-events)\n- [Add user hooks to an extension](/docs/extensions/publishers/user-hooks)\n- [Create user documentation for your extension](/docs/extensions/publishers/user-documentation)\n- [Publish an extension on Extensions Hub](/docs/extensions/publishers/upload-and-publish)\n- [Complete extension.yaml reference](/docs/extensions/reference/extension-yaml)"]]