Set Up Your Development Environment

To develop and run Salesforce Functions, install development tools. The tools vary depending on the language you use.

Prerequisites

To work with Salesforce Functions, install these tools:

  • Node.js 20 or higher to develop functions that use JavaScript or TypeScript. Use npm version 10.1.0 or higher.
  • OpenJDK 8 or higher and Apache Maven 3.6.3 or higher to develop functions that use Java.
  • Git CLI or GUI client to track changes in your function code. See Set up Git.
  • (Optional) To push changes to GitHub, create a github.com account.
  • (Optional) To save your function log output to a log drain, set up a log drain receiver or sign up with a service that can accept log drains. See Function Logging.

Install and Update Salesforce CLI

Salesforce CLI is a command-line interface that simplifies development and build automation when working with your Salesforce org and Salesforce Functions.

  1. Install Salesforce CLI.

  2. Update to the latest version.

    sf update
    

    note: Run the update command even if you previously installed Salesforce CLI. Check the Salesforce CLI Release Notes for the most recent CLI versions.

  3. Confirm you're using Salesforce CLI sf(v2).

    sf --version
    

    Example output:

    @salesforce/cli/2.23.20 darwin-x64 node-v20.10.0
    

    If your output looks like sfdx-cli/7.176.1 darwin-x64 node-v18.12.0, then you're using a deprecated Salesforce CLI version (sfdx v(7)) and you must update to sf (v2). See Move from sfdx (v7) to sf (v2).

  4. Install the Salesforce Functions plugin.

    sf plugins install @salesforce/plugin-functions
    
  5. Run sf plugins --core and view the list of all installed plug-ins. Make sure the Salesforce Functions plugin is installed.

    sf plugins --core
    

    The output looks like this:

    sf plugins --core
    @oclif/plugin-autocomplete 3.0.4 (core)
    @oclif/plugin-commands 3.1.0 (core)
    @oclif/plugin-help 6.0.9 (core)
    @oclif/plugin-not-found 3.0.7 (core)
    @oclif/plugin-plugins 4.1.14 (core)
    @oclif/plugin-search 1.0.10 (core)
    @oclif/plugin-update 4.1.7 (core)
    @oclif/plugin-version 2.0.11 (core)
    @oclif/plugin-warn-if-update-available 3.0.8 (core)
    @oclif/plugin-which 3.0.14 (core)
    @salesforce/cli 2.23.20 (core)
    apex 3.0.14 (core)
    auth 3.1.0 (core)
    command-reference 3.0.61
    data 3.0.13 (core)
    deploy-retrieve 2.2.12 (core)
    functions 1.22.11    <================= Functions plugin!
    info 3.0.13 (core)
    limits 3.1.0 (core)
    marketplace 1.0.15 (core)
    org 3.2.0 (core)
    packaging 2.0.1 (core)
    schema 3.1.0 (core)
    settings 2.0.14 (core)
    sobject 1.0.7 (core)
    source 3.0.10 (core)
    telemetry 3.1.8 (core)
    templates 56.0.8 (core)
    trust 3.2.5 (core)
    user 3.2.0 (core)
    
    Uninstalled JIT Plugins:
    community 3.0.10
    custom-metadata 3.0.12
    dev 2.1.3
    devops-center 1.2.5
    env 3.0.13
    signups 2.0.13
    @salesforce/sfdx-plugin-lwc-test 1.1.1
    @salesforce/sfdx-scanner 3.19.0
    

tip: If your versions are still outdated, then completely uninstall the Salesforce CLI and follow the previous instructions to reinstall.

Use the Salesforce SDK for Functions

To develop a function using TypeScript or Java, you need the Salesforce SDK.

note: When you generate a function with sf generate function, these dependencies appear in the example code.

See Salesforce SDK for Node.js Functions for more on using Node.js.

See Salesforce SDK for Java Functions for more on using Java.

Install Salesforce Extensions for Visual Studio Code

If you use Visual Studio Code, install Salesforce Extensions for Visual Studio Code.

To install, browse for the extension within Visual Studio Code, or go to Salesforce Extensions for Visual Studio Code and click Install the Salesforce Extensions.