Functions Framework

The Functions Framework lets you write lightweight functions that run in many different environments, including:

Functions Framework Introduction Video

In this video, Grant and Vinny introduce the Functions Framework:


  • Spin up a local development server for quick testing
  • Invoke a function in response to a request
  • Automatically unmarshal events conforming to the CloudEvents spec
  • Portable between serverless platforms

Node.js Functions Framework Quickstart

Create an index.js file with the following contents:

exports.helloWorld = (req, res) => {
  res.send('Hello, World');

To run a function locally, first create a package.json file using npm init:

npm init

Now install the Functions Framework:

npm install @google-cloud/functions-framework

Add a start script to package.json, with configuration passed via command-line arguments:

  "scripts": {
    "start": "functions-framework --target=helloWorld"

Use npm start to start the built-in local development server:

npm start
Serving function...
Function: helloWorld
URL: http://localhost:8080/

Send requests to this function using curl from another terminal window:

curl localhost:8080
# Output: Hello, World

Learn More

You can find more detailed documentation on how to use the Functions Framework on GitHub: