Environment Variables

Define the environment variables of your function.

Environment variables are the perfect tool to store configuration that defines the behavior of your functions. As part of the implementation of your functions, you can define in the function.config.json the environment variables your function will use. Our platform will ask the consumers for the values during the installation of the function.

What can you store in the environment variables?

  • Credentials of third-party services.

  • Function configuration in the form of stringifying JSON.

  • Firestore document or collection paths.

  • Boolean flags that enable or disable features.

Environment variables data types

You can think of the environment variables that your function needs different data types. Depending on your use case, you may need to store a more complex structure like a JSON, a boolean, or just plain text. We allow the definition of different types for a function.

Supported data types:

  • text

  • number

  • email

  • url

  • select

  • multiselect

  • boolean

  • JSON

  • firebaseCollectionPath

  • firebaseDocumentPath

  • color

Defining function environment variables

Every function can define its environment variables in the function.config.json file under the "env" property. An environment variable can be required during installation, or it can have a default value. See the example below.

{
    "name": "sendSignUpWelcomeEmail",
    "description": "Send a welcome email when users sign up throughout a SendGrid template.",
    "tags": [
        "sendGrid",
        "email",
        "authentication"
    ],
    "trigger": {
        "provider": "auth",
        "event": "user.create"
    },
    "env": [
        {
            "name": "SENDGRID_API_KEY",
            "description": "The API key to authenticate access to SendGrid services.",
            "required": true
        },
        {
            "name": "SENDGRID_SENDER_EMAIL",
            "description": "Email corresponding to SendGrid sender correctly verified.",
            "required": true
        },
        {
            "name": "SENDGRID_TEMPLATE_ID",
            "description": "The ID of SendGrid dynamic template that will be used to generate the welcome email.",
            "required": true
        }
    ]
}

Last updated