Overview
Serverless functions provide a way for private apps to run server-side code on HubSpot's infrastructure, typically to interact with HubSpot or third-party APIs on behalf of the app's React frontend that runs in a user's browser. Serverless functions for private apps are also called app functions.
The app functions dev server allows for app functions to run locally on a developer's machine instead of on HubSpot. This is useful for quick iterative development, epsecially when also running the React extension in local dev mode. However, there may differences between local and production execution.
Pre-requisites
- There is a project that contains the private app, which contains the app functions.
- The HubSpot CLI has been initialized for the project and a target account.
- The developer has a valid Personal Access Key (PAK) for the account. The PAK must contain at least the same scopes as those specified for the private app in the
app.json
file. - If an app function requires a secret, the developer must supply a value for the secret using a
.env
file in the app.functions
directory. This applies to the PRIVATE_APP_ACCESS_TOKEN, too. See dotenv for more information about .env files and their variants.
CAUTION: Add the pattern ".env*" to your .gitignore
file so that secrets do not get committed to a repository by mistake. Hidden files are automatically ignored when using the CLI upload
and watch
commands.
Usage
Usage
app-functions-dev-server
runs as part of the ui-extensions-dev-server
. To run and develop this codebase, follow the contribution guidelines in the dev server repository.