firebase-functions package

The 2nd gen API for Cloud Functions for Firebase. This SDK supports deep imports. For example, the namespace pubsub is available at firebase-functions/v2 or is directly importable from firebase-functions/v2/pubsub.

Functions

FunctionDescription
config()Store and retrieve project configuration data such as third-party API keys or other settings. You can set configuration values using the Firebase CLI as described in https://firebase.google.com/docs/functions/config-env.
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

ClassDescription
ChangeThe Cloud Functions interface for events that change state, such as Realtime Database or Cloud Firestore onWrite and onUpdate events.For more information about the format used to construct Change objects, see below.

Interfaces

InterfaceDescription
CloudEvent(BETA) A CloudEventBase 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.
EventHandlerOptionsAdditional fields that can be set on any event-handling function.
GlobalOptionsGlobalOptions are options that can be set across an entire project. These options are common to HTTPS and event handling functions.

Namespaces

NamespaceDescription
alerts
database
eventarc
firestore
https
identity
logger
params
pubsub
remoteConfig
scheduler
storage
tasks
testLab

Variables

VariableDescription
app

Type Aliases

Type AliasDescription
IngressSettingList of available options for IngressSettings.
MemoryOptionList of available memory options supported by Cloud Functions.
ParamsOfA type that maps all parameter capture gropus 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 is Record<string, string>
SupportedRegionList of all regions supported by Cloud Functions (2nd gen).
VpcEgressSettingList of available options for VpcConnectorEgressSettings.

config()

Using functions.config() is discouraged. See https://firebase.google.com/docs/functions/config-env.

Store and retrieve project configuration data such as third-party API keys or other settings. You can set configuration values using the Firebase CLI as described in https://firebase.google.com/docs/functions/config-env.

Signature:

exportdeclarefunctionconfig():Record<string,any>;

Returns:

Record<string, any>

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

setGlobalOptions()

Sets default options for all functions written using the 2nd gen SDK.

Signature:

exportdeclarefunctionsetGlobalOptions(options:GlobalOptions):void;

Parameters

ParameterTypeDescription
optionsGlobalOptionsOptions to set as default

Returns:

void

app

Signature:

app:{setEmulatedAdminApp:typeofsetEmulatedAdminApp;}

IngressSetting

List of available options for IngressSettings.

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 gropus 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 is Record<string, string>

Signature:

exporttypeParamsOf<PathPatternextendsstring|Expression<string>>=PathPatternextendsExpression<string>?Record<string,string>:stringextendsPathPattern?Record<string,string>:{[KeyinExtract<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 for VpcConnectorEgressSettings.

Signature:

exporttypeVpcEgressSetting="PRIVATE_RANGES_ONLY"|"ALL_TRAFFIC";