firebase-functions package

Functions

FunctionDescription
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

ClassDescription
ChangeThe 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

InterfaceDescription
BlockingFunctionThe function type for Auth Blocking triggers.
CloudFunctionThe 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.
DeploymentOptionsConfiguration options for a function that applies during function deployment.
EventContextThe context in which an event occurred.
EventContextAuthTokenhttps://firebase.google.com/docs/reference/security/database#authtoken
FailurePolicyConfiguration option for failure policy on background functions.
HttpsFunctionThe function type for HTTPS triggers. This should be exported from your JavaScript file to define a Cloud Function.
LegacyEventWire format for an event.
ResourceResource 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.
RunnableA Runnable has arun method which directly invokes the user-defined function - useful for unit testing.
RuntimeOptionsConfiguration options for a function that applicable at runtime.
ScheduleConfiguration options for scheduled functions.
ScheduleRetryConfigScheduler retry options. Applies only to scheduled functions.

Namespaces

NamespaceDescription
analytics
auth
database
firestore
https
logger
params
pubsub
remoteConfig
storage
tasks
testLab

Variables

VariableDescription
app
config
DEFAULT_FAILURE_POLICY
INGRESS_SETTINGS_OPTIONSList of available options for IngressSettings.
MAX_NUMBER_USER_LABELS
MAX_TIMEOUT_SECONDSCloud Functions max timeout value.
MIN_TIMEOUT_SECONDSCloud Functions min timeout value.
RESET_VALUESpecial configuration value to reset configuration to platform default.
SUPPORTED_REGIONSList of all regions supported by Cloud Functions.
VALID_MEMORY_OPTIONSList of available memory options supported by Cloud Functions.
VPC_EGRESS_SETTINGS_OPTIONSList 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

ParameterTypeDescription
callback() => unknowninitialization callback to be run before any function executes.

Returns:

void

optionsToEndpoint()

Signature:

exportdeclarefunctionoptionsToEndpoint(options:DeploymentOptions):ManifestEndpoint;

Parameters

ParameterTypeDescription
optionsDeploymentOptions

Returns:

ManifestEndpoint

optionsToTrigger()

Signature:

exportdeclarefunctionoptionsToTrigger(options:DeploymentOptions):any;

Parameters

ParameterTypeDescription
optionsDeploymentOptions

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

ParameterTypeDescription
regionsArray<(typeofSUPPORTED_REGIONS)[number] | string |Expression<string> | ResetValue>One of more region strings.

Returns:

FunctionBuilder

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

ParameterTypeDescription
runtimeOptionsRuntimeOptionsObject 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:

FunctionBuilder

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 theparams module immediately. Migration guide: https://firebase.google.com/docs/functions/config-env#migrate-config

Signature:

config:never

DEFAULT_FAILURE_POLICY

Signature:

DEFAULT_FAILURE_POLICY:FailurePolicy

INGRESS_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=58

MAX_TIMEOUT_SECONDS

Cloud Functions max timeout value.

Signature:

MAX_TIMEOUT_SECONDS=540

MIN_TIMEOUT_SECONDS

Cloud Functions min timeout value.

Signature:

MIN_TIMEOUT_SECONDS=0

RESET_VALUE

Special configuration value to reset configuration to platform default.

Signature:

RESET_VALUE:ResetValue

SUPPORTED_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.