Catch up on everything announced at Firebase Summit, and learn how Firebase can help you accelerate app development and run your app with confidence. Learn More

Cloud Functions (2nd gen) public preview

Stay organized with collections Save and categorize content based on your preferences.

Powered by Cloud Run and Eventarc, Cloud Functions for Firebase (2nd gen) has the potential to give you more powerful infrastructure, advanced control over performance and scalability, and more control of the functions runtime. This preview documentation explains what's new and what's available at this point in the preview for 2nd gen, and provides some guidance on how to use the new API, whether alone or together with Cloud Functions for Firebase (1st gen) APIs.

What's new in Cloud Functions for Firebase (2nd gen)

Changes and enhancements currently available in Cloud Functions for Firebase (2nd gen) include:

  • Function instances can now execute more than one request at a time. This feature is available for functions with one dedicated CPU or higher. Concurrency levels can be set on a per-function basis or across all functions with the setGlobalOptions method. If unspecified, new functions with 1 dedicated CPU or higher will default to 80 concurrent requests. See Allow concurrent requests.
  • Secure your callable and HTTP functions with a new cors setting. HTTP triggers also now have a cors setting to make CORS easier to manage.
  • Cloud Functions is now built on Cloud Run. If you're not familiar with Cloud Run, don't worry: building functions is just as easy as before. Cloud Run is a more modern serverless product that gives you better performance, better configuration, better monitoring, and more.
  • Google has collaborated with industry leaders to create the CloudEvents specification. Event handling functions now use this open standard as their event signature.
  • New trigger types include Firebase Alerts triggers, custom event triggers for Firebase Extensions, and task queue functions to run resource-intensive tasks on Cloud Tasks (task queue functions are also available in 1st gen).
  • The firebase-functions SDK has been reimagined as more native to modern JavaScript. You can configure 2nd gen functions globally, use options objects, and use modular imports.
  • HTTP functions can now have a 1 hour timeout (up from 9 minutes previously) if needed for long-running workloads.
  • Function instances now default to the default compute service account rather than the app engine service account.

Limitations during preview

This preview of Cloud Functions 2nd gen does not yet include the full set of planned functionality, nor does it provide full feature parity with Cloud Functions (1st gen). It is limited in terms of the triggers and regions available, and has the other current limitations described in this section.

Currently available Cloud Functions locations

Cloud Functions 2nd gen is currently available in the following regions:

  • europe-north1
  • europe-west1
  • europe-west4
  • us-central1
  • us-east1
  • us-west1

Currently available Cloud Functions triggers

Cloud Functions 2nd gen supports the following Firebase background triggers:

  • Firebase Realtime Database
  • Cloud Storage
  • Firebase Alerts
  • Pub/Sub
  • Callables
  • Cloud Tasks
  • HTTP
  • Scheduled functions
  • Firebase Authentication blocking functions
  • Firebase Remote Config
  • Firebase Test Lab

Cloud Functions 2nd gen does not currently support the following triggers:

  • Cloud Firestore
  • Firebase Authentication onCreate and onDelete
  • Google Analytics

Other limitations

These limitations also apply to Cloud Functions 2nd gen:

  • Function names are restricted to lowercase letters, numbers, and dashes.
  • Full observability is not yet built into the Firebase CLI or Firebase console. To observe your function instances, use the Google Cloud Console for the underlying Cloud Run service.
  • The Firebase Local Emulator Suite currently supports HTTP, Cloud Storage, and Pub/Sub functions in 2nd gen.
  • cloudfunctions.net URLs aren't yet supported for HTTP functions; temporarily, you'll see .run.app URLs instead. This limitation also affects invocation of callable and task queue functions (see the respective guides for acceptable workarounds).
  • Cold starts have not yet been optimized in 2nd gen, and temporarily may be significantly slower than in 1st gen. However, end users should experience fewer cold starts overall thanks to concurrency.