firebase-functions package Stay organized with collections Save and categorize content based on your preferences.
The 2nd gen API for Cloud Functions for Firebase. This SDK supports deep imports. For example, the namespacepubsub is available atfirebase-functions/v2 or is directly importable fromfirebase-functions/v2/pubsub.
Functions
| Function | Description |
|---|---|
| onInit(callback) | Registers a callback that should be run when in a production environment before executing any functions code. Calling this function more than once leads to undefined behavior. |
| setGlobalOptions(options) | Sets default options for all functions written using the 2nd gen SDK. |
Classes
| Class | Description |
|---|---|
| Change | The Cloud Functions interface for events that change state, such as Realtime Database or Cloud FirestoreonWrite andonUpdate events.For more information about the format used to constructChange objects, see below. |
Interfaces
| Interface | Description |
|---|---|
| CloudEvent | (BETA) ACloudEventBase is the base of a cross-platform format for encoding a serverless event. For more information, see https://github.com/cloudevents/spec. |
| CloudFunction | (BETA) A handler for CloudEvents. |
| EventHandlerOptions | Additional fields that can be set on any event-handling function. |
| GlobalOptions | GlobalOptions are options that can be set across an entire project. These options are common to HTTPS and event handling functions. |
Namespaces
| Namespace | Description |
|---|---|
| alerts | |
| database | |
| dataconnect | |
| eventarc | |
| firestore | |
| https | |
| identity | |
| params | |
| pubsub | |
| remoteConfig | |
| scheduler | |
| storage | |
| tasks | |
| testLab |
Variables
| Variable | Description |
|---|---|
| app | |
| config | |
| logger | Logger object containing all logging methods.Mockable for testing purposes. |
| traceContext |
Type Aliases
| Type Alias | Description |
|---|---|
| IngressSetting | List of available options forIngressSettings. |
| MemoryOption | List of available memory options supported by Cloud Functions. |
| ParamsOf | A type that maps all parameter capture groups into keys of a record. For example, ParamsOf<"users/{uid}"> is { uid: string } ParamsOf<"users/{uid}/logs/{log}"> is { uid: string; log: string } ParamsOf<"some/static/data"> is {}For flexibility reasons, ParamsOf |
| SupportedRegion | List of all regions supported by Cloud Functions (2nd gen). |
| VpcEgressSetting | List of available options forVpcConnectorEgressSettings. |
onInit()
Registers a callback that should be run when in a production environment before executing any functions code. Calling this function more than once leads to undefined behavior.
Signature:
exportdeclarefunctiononInit(callback:()=>unknown):void;Parameters
| Parameter | Type | Description |
|---|---|---|
| callback | () => unknown | initialization callback to be run before any function executes. |
Returns:
void
setGlobalOptions()
Sets default options for all functions written using the 2nd gen SDK.
Signature:
exportdeclarefunctionsetGlobalOptions(options:GlobalOptions):void;Parameters
| Parameter | Type | Description |
|---|---|---|
| options | GlobalOptions | Options to set as default |
Returns:
void
app
Signature:
app:{setEmulatedAdminApp:typeofsetEmulatedAdminApp;}config
Warning: This API is now obsolete.
functions.config()has been removed in firebase-functions v7. Migrate to environment parameters using theparamsmodule immediately. Migration guide: https://firebase.google.com/docs/functions/config-env#migrate-config
Signature:
config:neverlogger
Logger object containing all logging methods.
Mockable for testing purposes.
Signature:
logger:{write:typeofwrite;debug:typeofdebug;log:typeoflog;info:typeofinfo;warn:typeofwarn;error:typeoferror;}traceContext
Signature:
traceContext:AsyncLocalStorage<TraceContext>IngressSetting
List of available options forIngressSettings.
Signature:
exporttypeIngressSetting="ALLOW_ALL"|"ALLOW_INTERNAL_ONLY"|"ALLOW_INTERNAL_AND_GCLB";MemoryOption
List of available memory options supported by Cloud Functions.
Signature:
exporttypeMemoryOption="128MiB"|"256MiB"|"512MiB"|"1GiB"|"2GiB"|"4GiB"|"8GiB"|"16GiB"|"32GiB";ParamsOf
A type that maps all parameter capture groups into keys of a record. For example, ParamsOf<"users/{uid}"> is { uid: string } ParamsOf<"users/{uid}/logs/{log}"> is { uid: string; log: string } ParamsOf<"some/static/data"> is {}
For flexibility reasons, ParamsOf
Signature:
exporttypeParamsOf<PathPatternextendsstring|Expression<string>>=PathPatternextendsExpression<string>?Record<string,string>:stringextendsPathPattern?Record<string,string>:{[KeyinVarName<Split<NullSafe<Exclude<PathPattern,Expression<string>>>,"/">[number]>]:string;};SupportedRegion
List of all regions supported by Cloud Functions (2nd gen).
Signature:
exporttypeSupportedRegion="asia-east1"|"asia-northeast1"|"asia-northeast2"|"europe-north1"|"europe-west1"|"europe-west4"|"us-central1"|"us-east1"|"us-east4"|"us-west1"|"asia-east2"|"asia-northeast3"|"asia-southeast1"|"asia-southeast2"|"asia-south1"|"australia-southeast1"|"europe-central2"|"europe-west2"|"europe-west3"|"europe-west6"|"northamerica-northeast1"|"southamerica-east1"|"us-west2"|"us-west3"|"us-west4";VpcEgressSetting
List of available options forVpcConnectorEgressSettings.
Signature:
exporttypeVpcEgressSetting="PRIVATE_RANGES_ONLY"|"ALL_TRAFFIC";Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-11-10 UTC.