Newer Version Available
Create Aura Components Using the Salesforce CLI
- Salesforce CLI
- Visual Studio Code or another code editor
- Salesforce Extension Pack, if using Visual Studio Code
- A Developer Edition org
To install the Salesforce CLI and verify the installation, follow the instructions at Salesforce DX Setup Guide.
Use your favorite code editor with the Salesforce CLI. We recommend using Visual Studio Code because its Salesforce Extension Pack provides powerful features for working with the Salesforce CLI, the Lightning Component framework, Apex, and Visualforce.
- Visual Studio Code (VS Code)
- Salesforce Extension Pack for Visual Studio Code
To create and deploy an Aura Component to your org:
-
Create a Salesforce DX project.
- In Visual Studio code, open the Command Palette by pressing Ctrl+Shift+P on Windows or Cmd+Shift+P on macOS.
- Type SFDX and then select SFDX: Create Project.
- Enter HelloAuraComponent and then press Enter. Select a folder to store the project.
-
Click Create Project. You should see something
like this in your Visual Studio Code workspace.
-
Create an Aura component.
- Open the Command Palette and select SFDX: Create Lightning Component.
- Enter a name for your component, such as myComponent. Press Enter.
-
Enter the directory for your component or press
Enter to accept the default. The default
directory is force-app/main/default/aura. You
should see a similar directory like this.
-
Open myComponent.cmp and replace its
content.
-
Authenticate to your org. This step uses a Dev Hub org.
- Open the Command Palette and select SFDX: Authorize a Dev Hub Org. A browser window opens with a Salesforce login page.
-
Log in to your org. If prompted to allow access, click
Allow.
After you authenticate in the browser, the CLI remembers your credentials. The success message looks like this.
If the authentication fails, follow the troubleshooting guide at Salesforce DX Setup Guide.
-
Deploy your files.
-
In the Visual Studio Code terminal, run this command.
The success message looks like this.
-
In the Visual Studio Code terminal, run this command.