---
title: "New runtime configuration options with Cloud Functions for Firebase"
description: "New runtime configuration options with Cloud Functions for Firebase"
published: "2018-08-13"
last_updated: "2018-08-13"
authors:
  - "Doug Stevenson (Developer Advocate)"
categories:
  - "Cloud Functions"
  - "Cloud Next"
  - "Launch"
canonical_url: "https://firebase.blog/posts/2018/08/cloud-functions-for-firebase-config-node-8-timeout-memory-region"
---

# New runtime configuration options with Cloud Functions for Firebase

*Published August 13, 2018 by Doug Stevenson (Developer Advocate)*

---
Recently, at Cloud Next 2018, we saw some hotly anticipated updates to Cloud Functions, and in particular, the [general availability of Cloud Functions for Firebase](https://cloud.google.com/blog/products/gcp/cloud-functions-serverless-platform-is-generally-available). As part of that release, there are some additional configurations you can use in your functions when deploying with the Firebase CLI. Let's take a look!

### Node.js 8 runtime now available 
You can now target Node.js 8 as a runtime option (in beta, targeting version 8.11.1). What's in it for you? Most notably, Node.js 8 offers performance improvements with the V8 JavaScript runtime, and the much-desired ability to use ECMAScript 2017 async/await syntax with native JavaScript, without having to transpile. You can read more about async functions [here](https://developers.google.com/web/fundamentals/primers/async-functions).

You can get started [deploying functions to the Node.js 8](https://firebase.google.com/docs/functions/manage-functions#set_nodejs_version) runtime by updating the Firebase CLI to at least version 4.0.0. To get the latest:

```js
$ npm install -g firebase-tools@latest
$ firebase --version
4.0.0
```

You'll also need to be using at least version 2.0.1 of the firebase-functions module in your project:

```js
$ npm install firebase-functions@latest
```

After that, you'll need to make a small change to your project's configuration in package.json. Simply add the following key and value at the top level of the JSON configuration:

```js
"engines": { "node": "8" }
```

Now, when you run `firebase deploy`, the CLI will give you some feedback about the deployment runtime in its output:

```js
i  functions: updating Node.js 8 function onMessageCreate(us-central1)...
i  functions: updating Node.js 8 function onMessageDelete(us-central1)...
```

For those of you using TypeScript to write your functions ([and I really think you should!](https://firebase.googleblog.com/2018/01/why-you-should-use-typescript-for.html)), you can also update your TypeScript configuration in tsconfig.json to target ECMAScript 2017 instead of ES6. Your new configuration will have a `compilerOptions` block that looks something like the following. Note that `target` and `lib` values are now changed to "es2017" instead of "es6".

```json
  "compilerOptions": {
    "target": "es2017",
    "lib": ["es2017"],
    "module": "commonjs",
    ...
  }
```

With this, you'll notice that your transpiled TypeScript no longer converts async/await to JavaScript generators, meaning it'll be a bit tighter and faster.

Google Cloud Functions also now allow developers to [build with Python](https://cloud.google.com/functions/docs/concepts/python-runtime), however, the Firebase CLI does not currently support that runtime.

### New runtime configuration options 
Using the Firebase CLI, you can [specify regions per-function](https://firebase.google.com/docs/functions/manage-functions#modify-region) to bring your serverless infrastructure closer to your customers or other cloud infrastructure. You can also [specify memory allocation and timeout](https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation) on a per-function basis, tailoring performance to your use cases.

You can do this with the firebase-functions module that you're already using to build your functions, and you can apply these configurations to any type of trigger. Note the new `region` and `runWith` methods in this code sample:

```js
const functions = require('firebase-functions');

exports.myHttpFunction = functions
  // Choose a region other than the default us-central1
  .region('europe-west1')
  // Increased memory, decreased timeout (compared to defaults)
  .runWith({ memory: '1GB', timeoutSeconds: 120 })
  .https
  .onRequest((req, res) = > {
     // time and memory intensive tasks
     res.send('Hello world');
  });
```

Version 2.0.1 or later of the firebase-functions module is required.

### Getting started with Cloud Functions for Firebase 
If you're just getting started with the Firebase SDKs for Cloud Functions, try following [our step-by-step codelab](https://codelabs.developers.google.com/codelabs/firebase-cloud-functions/#0) and visiting the [documentation](https://firebase.google.com/docs/functions/). We also have a video tutorial to help get you set up using TypeScript:

We hope you find these new functionality helpful, and we look forward to continue giving you more features to help you build truly serverless apps!
