Navigation

Functions

Introduction

Stitch Functions allow you to define and execute server-side logic for your application. You can call functions from your client applications as well as from other functions and in JSON expressions throughout Stitch.

Functions are written in modern JavaScript (ES6+) and execute in a serverless manner. When you call a function, you can dynamically access components of the current application as well as information about the request to execute the function and the logged in user that sent the request.

Use Cases

You can use functions to handle low-latency, short-running connection logic and other server-side interactions. Functions are particularly useful when you want to work with multiple services, behave dynamically based on the current user, or abstract away implementation details from your client applications.

Stitch also uses functions internally for incoming webhooks and triggers. The functions that you create for these components are regular Stitch functions that take specific arguments depending on the service.

Behavior

  • Stitch automatically encodes values returned from functions as Extended JSON.
  • Functions do not continue to execute after they return. You cannot use functions with asynchronous callbacks or event listeners. If you need to do asynchronous work in a function, use a promise.

Constraints

  • Function runtime is limited to 60 seconds.
  • Function memory usage is limited to 256MB.
  • Functions currently do not support the following ES6+ features:
    • Module Imports (i.e. import and require)
    • New Global Object Types (i.e. Map, WeakMap, Set, WeakSet, Symbol, Proxy)
    • New Math, Number, String, Array, and Object APIs (e.g. Array.protoype.fill, Array.protoype.includes, Object.assign)

Usage Guides

Guide Description
Define a Function Learn how to write and add new functions to your Stitch application.
Call a Function Learn how to execute functions that you’ve defined from a client application or from another Stitch component.
Access Function Context Learn how to access runtime information and interfaces to other components of your application from within a function.

Reference Documentation

Subject Description
Context Modules Includes detailed information about specific application context modules as well as examples of runtime data objects.
Utility Packages Includes detailed information about global utility packages.