Front-end8 min read
Salesforce from scratch: free org, CLI and VS Code to study
Step by step to set up a free Salesforce environment: Developer Edition, Salesforce CLI, VS Code and your first LWC and Aura components deployed to your org.

You can't learn LWC and Aura just by reading. You need an org to deploy the component to, see it on screen and break things freely. The good news is you can set all of that up for free, in an afternoon.
This is a follow-along tutorial. By the end you'll have your own org, a VS Code project connected to it and two components live: one in LWC and one in Aura. It's the base for part 2, where we put an iframe inside Salesforce and exchange messages with it through postMessage.
An honest note: the commands were checked against Salesforce CLI 2.159, and the rest follows the official documentation, linked at the end. Sign-up screens change over time, so if a button has a different name, go by what it does.
TL;DR#
- Create a Developer Edition at developer.salesforce.com/signup. It's free and it's yours.
- Install the Salesforce CLI (
sf), VS Code with the Salesforce Extension Pack and a JDK 21 for Apex. - Create the project with
sf template generate projectand connect it to the org withsf org login web. - Generate, deploy and put it on screen:
sf template generate lightning component,sf project deploy startand the Lightning App Builder. - Old tutorials use
sfdx force:.... Those commands were retired. Today everything starts withsf.
What you'll have at the end#
- a Developer Edition org with your user;
- the Salesforce CLI installed and authenticated to it;
- a Salesforce DX project open in VS Code;
- an LWC (
helloWorld) and an Aura component (helloAura) deployed and visible on a page.
1. Create your org#
An org is your "Salesforce": an environment with users, data, settings and the code you deploy. To study, the right choice is the Developer Edition, which is free.
- Open developer.salesforce.com/signup.
- Fill in name, email and company (it can be "Studies").
- For Username, use an email-like format that's only yours, such as
yourname@salesforce-study.dev. It doesn't need to be a real mailbox, but it must be unique across all of Salesforce, somaria@gmail.comis probably taken. - Confirm the email that lands in your inbox and set the password.
Keep that username. It's what you use to log in to the org and to connect the CLI.
If you do Trailhead modules, you'll also see the Trailhead Playground. It's meant for the challenges there. For this tutorial, the Developer Edition is simpler, because you log in directly with username and password.
2. Install the tools#
Salesforce CLI#
It's the command line that creates the project, connects to the org and deploys code. Two ways, pick only one (installing both ways confuses the PATH, and the documentation itself warns about it):
- Installer: download the
.pkg(macOS) or.exe(Windows) from the CLI download page and follow the wizard. - npm: if you already have Node.js LTS installed:
npm install @salesforce/cli --globalClose and reopen the terminal and check:
sf --versionVS Code and the extensions#
- Install VS Code.
- In the extensions tab, search for Salesforce Extension Pack (published by Salesforce) and install it.
- Install a JDK 21. The Apex extension needs Java to work. If VS Code doesn't find it on its own, point to the Java folder in the
salesforcedx-vscode-apex.java.homesetting (the installation folder, not the executable).
3. Create the project#
In a terminal, in the folder where you keep your projects:
sf template generate project --name salesforce-study
cd salesforce-study
code .The CLI creates a Salesforce DX project. What matters for now:
salesforce-study/
├── force-app/main/default/ # everything that goes to the org: lwc/, aura/, classes/, staticresources/...
├── sfdx-project.json # project config (API version, default folder)
├── .forceignore # what never goes to the org
└── package.json # Jest, ESLint and Prettier already set upIf you follow an older tutorial, you'll see sf project generate or sfdx force:project:create. The first one still works, but the CLI warns that it was replaced by sf template generate project. The second one is from the old generation of the CLI, which stopped getting updates in 2023.
4. Connect the project to the org#
sf org login web --alias study --set-defaultThe browser opens on the Salesforce login screen. Log in with the username and password from step 1 and click Allow. You can close the tab afterwards.
--alias studygives the org a short nickname, so you don't type the username every time.--set-defaultmakes it the project's default org: the next commands go to it without you having to say so.
To check:
sf org listThe study org shows up in the list. And to open the org in the browser, already logged in:
sf org open5. Your first LWC#
Generate the component inside the lwc folder:
sf template generate lightning component --name helloWorld --type lwc --output-dir force-app/main/default/lwcThe CLI creates helloWorld.html, helloWorld.js, helloWorld.js-meta.xml and a test in __tests__. Replace the content of the first three:
<template>
<lightning-card title="Hello, Salesforce">
<div class="slds-p-horizontal_medium">
<lightning-input label="Your name" value={name} onchange={handleChange}></lightning-input>
<p class="slds-m-top_small">Hi, {name}! This LWC came from your VS Code.</p>
</div>
</lightning-card>
</template>import { LightningElement } from 'lwc';
export default class HelloWorld extends LightningElement {
name = 'dev';
handleChange(event) {
this.name = event.target.value;
}
}<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>68.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>
<target>lightning__RecordPage</target>
</targets>
</LightningComponentBundle>The js-meta.xml file is what confuses people most at the start. The CLI generates it with isExposed set to false, and that way the component exists in the org but doesn't show up anywhere. isExposed set to true plus the list of targets say which pages it can be placed on.
Deploy:
sf project deploy start --source-dir force-appThe CLI shows a table with what went up. If there's an error, it points to the file and the line.
Put the component on screen#
- Run
sf org open. - On the Home page, click the gear in the top corner and then Edit Page. The Lightning App Builder opens.
- In the list on the left, under Custom, drag
helloWorldonto the page. - Click Save. The first time it asks about activation: choose Activate and set it as the org default.
- Go back to Home. The card is there, and the text changes as you type.
6. Your first Aura component#
Now the same path in Aura, so you can see both side by side:
sf template generate lightning component --name helloAura --type aura --output-dir force-app/main/default/auraAura generates more files (controller, helper, renderer, design, CSS, documentation, icon). To start, only the .cmp and the controller matter:
<aura:component implements="flexipage:availableForAllPageTypes" access="global">
<aura:attribute name="name" type="String" default="dev" />
<lightning:card title="Hello, Aura">
<div class="slds-p-horizontal_medium">
<lightning:input label="Your name" value="{!v.name}" />
<p class="slds-m-top_small">Hi, {!v.name}! This component is Aura.</p>
</div>
</lightning:card>
</aura:component>Notice two differences:
- Aura has no
js-meta.xml. What makes the component available in the App Builder is theflexipage:availableForAllPageTypesinterface. value="{!v.name}"already binds the field both ways. In LWC you write theonchangeand update the property by hand. It's more code, but it's clear where each change comes from.
Deploy again and put helloAura on the same page, the same way as before:
sf project deploy start --source-dir force-app7. The day-to-day loop#
From here on, the rhythm is always the same:
- edit the file in VS Code;
- deploy only what changed, to go faster;
- reload the org page.
sf project deploy start --source-dir force-app/main/default/lwc/helloWorldIn VS Code you can do step 2 without a terminal: right-click the file or folder and choose SFDX: Deploy This Source to Org.
And when you change something directly in the org (a new field, a page in the App Builder) and want to bring it into the project:
sf project retrieve start --metadata FlexiPageCommon problems#
- The component doesn't show up in the App Builder. In LWC, check
isExposedset totrueand thetargetfor the right page. In Aura, check theflexipage:availableForAllPageTypesinterface. - I deployed, but the screen didn't change. Lightning keeps a cache in the browser. For studying, it's worth turning it off: in Setup, search for Session Settings and uncheck the secure and persistent browser caching option. In your study org, this only makes pages a bit slower.
- "This username already exists". The username is unique across all of Salesforce. Make up a more specific email-like format.
- The Apex extension complains about Java. Install JDK 21 and point to the folder in
salesforcedx-vscode-apex.java.home. - A tutorial tells you to run
sfdx force:.... That's the old CLI. Look for thesfequivalent, such assf project deploy startinstead ofsfdx force:source:deploy.
Next step#
With the org up and both components live, part 2 puts an external page inside Salesforce with an iframe and gets both sides talking through postMessage: in LWC, in Aura and with lightning:container, which is Aura's official way to do it. It includes the Trusted URLs setting that allows the iframe and the origin check that keeps the conversation safe.
Checklist#
- Developer Edition created, email confirmed, password set.
sf --versionresponds.- VS Code with Salesforce Extension Pack and JDK 21.
- Project created with
sf template generate project. sf org login web --alias study --set-defaultdone, org showing insf org list.helloWorldwithisExposedset totrueand targets.helloAurawithflexipage:availableForAllPageTypes.- Both deployed with
sf project deploy startand visible on Home.
References#
Comments
Sign in with your GitHub account to comment.
Read next


Front-end10 min
Signals in Angular 22: signal, computed, effect and beyond

Front-end12 min
Smart and dumb components in Angular and React, in 2026