Skip to content

Your first Salesforce project

This page walks you from a single-file Vertex script to a real project that builds to Apex class files and deploys to a Salesforce org.

It assumes you have:

A Vertex project has two config files at the root: sfdx-project.json (Salesforce’s) and vertex.jsonc (Vertex’s). The first tells the Salesforce tooling where your Apex source lives; the second configures the Vertex build.

The conventional layout:

my-project/
├── sfdx-project.json
├── vertex.jsonc
├── src/ # .vtx source goes here
│ └── hello.vtx
└── force-app/
└── main/
└── vertex/
└── classes/ # vertex build writes .cls files here

A minimal sfdx-project.json:

{
"packageDirectories": [
{ "path": "force-app", "default": true }
],
"sourceApiVersion": "66.0"
}

Scaffold vertex.jsonc from the project root:

$ vertex init
Created vertex.jsonc. Edit it to customize your build.

That writes the recommended defaults:

{
"src": "src",
"out": "force-app/main/vertex/classes",
"clean": true
}

Vertex programs that run as real Apex classes expose a pub fn run entry point. Create src/hello.vtx:

pub fn run(): Void {
debug "Hello from Vertex on Salesforce!"
}

This compiles to a public static void vtx_run() method on a generated Apex class.

From the project root:

$ vertex build
Success! Built 1 class(es) to /path/to/my-project/force-app/main/vertex/classes

Look inside force-app/main/vertex/classes/ and you will see a .cls file and a .cls-meta.xml file ready for deployment.

$ sf project deploy start --target-org <alias>

Use the alias you set up with sf org login. Do not pass --source-dir or --metadata: the sf CLI tracks local changes internally.

Create run-hello.apex:

Hello.vtx_run();

Then:

$ sf apex run --target-org <alias> --file run-hello.apex

You should see your debug line in the Apex log.

For day-to-day iteration, you rarely need the org. The loop is:

  1. Edit a .vtx file.
  2. vertex run <file> to execute it locally (millisecond feedback).
  3. vertex test to run your *_test.vtx files.
  4. vertex build and sf project deploy start when you are ready to ship.

See The vertex CLI for the full command reference and Testing for the test runner.