Function Store
  • Home
  • Getting started
    • Introduction
    • Installing a function
    • Reconfiguring a function
    • Uninstalling a function
    • FAQs
  • Reference
    • Requirements
      • Assign Roles
        • User permissions
      • Link a Billing account to your project
      • Enable the APIs
    • Projects
      • How to add a project
      • How to set up a project
    • Functions
      • Benefits
      • Use cases
      • Authentication when installing
      • Runtime configuration
      • Deploying with a ZIP file
    • Policies
      • How to add a Policy
      • How to remove a Policy
    • Authentication
      • Users
      • Roles
      • Permissions
    • Secrets
      • Creating a Secret
      • Using a Secret
      • Changing the value for a Secret
      • Deactivating a Secret
  • developers
    • Overview
    • Getting Started
    • Set up
    • Workspaces
      • Create a workspace
      • Workspace boilerplate
      • Node engines
    • Writing Functions
      • Function Anatomy
      • Configuration file
      • Function Triggers
      • Environment Variables
        • Type "text"
        • Type "number"
        • Type "email"
        • Type "url"
        • Type "json"
        • Type "boolean"
        • Type "select"
        • Type "multiselect"
        • Type "firestoreDocumentPath"
        • Type "firestoreCollectionPath"
        • Type "color"
      • Documentation
    • Push/Update your functions in the cloud
    • Continuous Integration
    • Publish functions in the Marketplace
    • Emulators
      • Initialize emulators in your workspace
      • Environment variables
      • Starting emulators
      • Testing your functions in the emulator
      • Importing existing data into local emulators
        • Exporting data from Cloud Firestore to local emulator
        • Exporting user accounts from Firebase to local emulator
    • Visual Studio Code Extension
      • Installing the extension
      • Extension UI
      • Functions list
      • Creating and editing functions
      • Emulators
      • Extension settings
      • Troubleshooting
        • "Command not found" error when executing a command
  • Billing
    • Understanding Billing
  • Security
    • Security
  • Resources
    • Events and Triggers
    • Best Practices
      • How to log events in functions?
    • Document your Functions
    • Editorial guidelines
    • Our Processes
      • Use Cases Analysis
  • Use cases
    • Custom Stripe Checkout
Powered by GitBook
On this page
  • What can you store in the environment variables?
  • Environment variables data types
  • Defining function environment variables

Was this helpful?

  1. developers
  2. Writing Functions

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
        }
    ]
}

PreviousFunction TriggersNextType "text"

Last updated 3 years ago

Was this helpful?