Create Lightning Web Components
You can use Salesforce CLI to create Lightning web components in your local
Salesforce DX project. The generated files live in a lwc directory in a package directory of your project.
- Open a terminal (macOS and Linux) or command prompt Windows and change to your Salesforce DX project directory.
- Create the lwc directory in the location you want to generate the Lightning app and Aura components. For example, if you want to generate them in the default package directory, create the force-app/main/default/aura directory if it doesn’t exist.
-
Create the Lightning web component; specify the component name with the --name flag and the lwc directory with the --output-dir flag.
sf lightning generate component --type lwc --name myLightningWebComponent --output-dir force-app/main/default/lwc
Use the project deploy start command to deploy your new Lightning web component to your org.
sf project deploy start --metadata LightningComponentBundle:myLightningWebComponent