firebase-functions package Stay organized with collections Save and categorize content based on your preferences.
Functions
| Function | Description |
|---|---|
| firebaseConfig() | Get the fields you need to initialize a Firebase app |
| 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. |
| optionsToEndpoint(options) | |
| optionsToTrigger(options) | |
| region(regions) | Configure the regions that the function is deployed to. |
| runWith(runtimeOptions) | Configure runtime options for the function. |
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. |
| FunctionBuilder |
Interfaces
| Interface | Description |
|---|---|
| BlockingFunction | The function type for Auth Blocking triggers. |
| CloudFunction | The function type for all non-HTTPS triggers. This should be exported from your JavaScript file to define a Cloud Function.This type is a special JavaScript function which takes a templatedLegacyEvent object as its only argument. |
| DeploymentOptions | Configuration options for a function that applies during function deployment. |
| EventContext | The context in which an event occurred. |
| EventContextAuthToken | https://firebase.google.com/docs/reference/security/database#authtoken |
| FailurePolicy | Configuration option for failure policy on background functions. |
| HttpsFunction | The function type for HTTPS triggers. This should be exported from your JavaScript file to define a Cloud Function. |
| LegacyEvent | Wire format for an event. |
| Resource | Resource is a standard format for defining a resource (google.rpc.context.AttributeContext.Resource). In Cloud Functions, it is the resource that triggered the function - such as a storage bucket. |
| Runnable | A Runnable has arun method which directly invokes the user-defined function - useful for unit testing. |
| RuntimeOptions | Configuration options for a function that applicable at runtime. |
| Schedule | Configuration options for scheduled functions. |
| ScheduleRetryConfig | Scheduler retry options. Applies only to scheduled functions. |
Namespaces
| Namespace | Description |
|---|---|
| analytics | |
| auth | |
| database | |
| firestore | |
| https | |
| logger | |
| params | |
| pubsub | |
| remoteConfig | |
| storage | |
| tasks | |
| testLab |
Variables
| Variable | Description |
|---|---|
| app | |
| config | |
| DEFAULT_FAILURE_POLICY | |
| INGRESS_SETTINGS_OPTIONS | List of available options for IngressSettings. |
| MAX_NUMBER_USER_LABELS | |
| MAX_TIMEOUT_SECONDS | Cloud Functions max timeout value. |
| MIN_TIMEOUT_SECONDS | Cloud Functions min timeout value. |
| RESET_VALUE | Special configuration value to reset configuration to platform default. |
| SUPPORTED_REGIONS | List of all regions supported by Cloud Functions. |
| VALID_MEMORY_OPTIONS | List of available memory options supported by Cloud Functions. |
| VPC_EGRESS_SETTINGS_OPTIONS | List of available options for VpcConnectorEgressSettings. |
firebaseConfig()
Get the fields you need to initialize a Firebase app
Signature:
exportdeclarefunctionfirebaseConfig():AppOptions|null;Returns:
AppOptions | null
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
optionsToEndpoint()
Signature:
exportdeclarefunctionoptionsToEndpoint(options:DeploymentOptions):ManifestEndpoint;Parameters
| Parameter | Type | Description |
|---|---|---|
| options | DeploymentOptions |
Returns:
ManifestEndpoint
optionsToTrigger()
Signature:
exportdeclarefunctionoptionsToTrigger(options:DeploymentOptions):any;Parameters
| Parameter | Type | Description |
|---|---|---|
| options | DeploymentOptions |
Returns:
any
region()
Configure the regions that the function is deployed to.
Signature:
exportdeclarefunctionregion(...regions:Array<(typeofSUPPORTED_REGIONS)[number]|string|Expression<string>|ResetValue>):FunctionBuilder;Parameters
| Parameter | Type | Description |
|---|---|---|
| regions | Array<(typeofSUPPORTED_REGIONS)[number] | string |Expression<string> | ResetValue> | One of more region strings. |
Returns:
Example 1
functions.region('us-east1')
Example 2
functions.region('us-east1', 'us-central1')
runWith()
Configure runtime options for the function.
Signature:
exportdeclarefunctionrunWith(runtimeOptions:RuntimeOptions):FunctionBuilder;Parameters
| Parameter | Type | Description |
|---|---|---|
| runtimeOptions | RuntimeOptions | Object with optional fields: 1.memory: amount of memory to allocate to the function, possible values are: '128MB', '256MB', '512MB', '1GB', '2GB', '4GB', and '8GB'. 2.timeoutSeconds: timeout for the function in seconds, possible values are 0 to 540. 3.failurePolicy: failure policy of the function, with booleantrue being equivalent to providing an empty retry object. 4.vpcConnector: id of a VPC connector in same project and region. 5.vpcConnectorEgressSettings: when a vpcConnector is set, control which egress traffic is sent through the vpcConnector. 6.serviceAccount: Specific service account for the function. 7.ingressSettings: ingress settings for the function, which control where a HTTPS function can be called from.Value must not be null. |
Returns:
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:neverDEFAULT_FAILURE_POLICY
Signature:
DEFAULT_FAILURE_POLICY:FailurePolicyINGRESS_SETTINGS_OPTIONS
List of available options for IngressSettings.
Signature:
INGRESS_SETTINGS_OPTIONS:readonly["INGRESS_SETTINGS_UNSPECIFIED","ALLOW_ALL","ALLOW_INTERNAL_ONLY","ALLOW_INTERNAL_AND_GCLB"]MAX_NUMBER_USER_LABELS
Signature:
MAX_NUMBER_USER_LABELS=58MAX_TIMEOUT_SECONDS
Cloud Functions max timeout value.
Signature:
MAX_TIMEOUT_SECONDS=540MIN_TIMEOUT_SECONDS
Cloud Functions min timeout value.
Signature:
MIN_TIMEOUT_SECONDS=0RESET_VALUE
Special configuration value to reset configuration to platform default.
Signature:
RESET_VALUE:ResetValueSUPPORTED_REGIONS
List of all regions supported by Cloud Functions.
Signature:
SUPPORTED_REGIONS:readonly["us-central1","us-east1","us-east4","us-west2","us-west3","us-west4","europe-central2","europe-west1","europe-west2","europe-west3","europe-west6","asia-east1","asia-east2","asia-northeast1","asia-northeast2","asia-northeast3","asia-south1","asia-southeast1","asia-southeast2","northamerica-northeast1","southamerica-east1","australia-southeast1"]VALID_MEMORY_OPTIONS
List of available memory options supported by Cloud Functions.
Signature:
VALID_MEMORY_OPTIONS:readonly["128MB","256MB","512MB","1GB","2GB","4GB","8GB"]VPC_EGRESS_SETTINGS_OPTIONS
List of available options for VpcConnectorEgressSettings.
Signature:
VPC_EGRESS_SETTINGS_OPTIONS:readonly["VPC_CONNECTOR_EGRESS_SETTINGS_UNSPECIFIED","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.