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 is any directory containing an sfdx-project.json file. The file tells the Salesforce tooling where your Apex source lives; Vertex uses the same file to locate your Vertex source.

The conventional layout:

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

A minimal sfdx-project.json:

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

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 force-app/main/default/classes/

Look inside force-app/main/default/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.