LearnFrenzy
Sign in Take a free test

Getting Started with LWC · Lesson 1 of 25

What Is LWC? Lightning Web Components Explained

5 min read Updated Nov 8, 2026 Saurabh Samir

Lightning Web Components (LWC) is Salesforce's framework for building user interfaces on the Salesforce platform. A component is a small, self-contained piece of UI – a contact card, a quote calculator, an approval panel – that admins can drop onto record pages, app pages, Experience Cloud sites, flows and the mobile app. Since its launch in 2019 LWC has become the standard way to build custom Salesforce UI, and it's an expected skill for Salesforce developers.

In this lesson

  • What LWC is built on – web standards
  • LWC vs Aura components
  • Where LWC runs in Salesforce
  • How a component works, end to end

Built on web standards

Before LWC, Salesforce UI was built with Visualforce (server-rendered pages) and then Aura (a proprietary JavaScript framework). By 2019, browsers had caught up: they natively supported custom elements, shadow DOM, ES modules and classes. LWC was designed as a thin layer on top of those standards. You write modern JavaScript and HTML; LWC adds only what browsers don't provide – reactivity, data binding and access to Salesforce data.

The LWC stack

  1. Your componentsHTML templates, JavaScript classes, CSS
  2. Lightning platform servicesLightning Data Service, base components (lightning-*), Apex, navigation, messaging
  3. LWC enginereactivity, templates, decorators, security (Lightning Web Security)
  4. Web standards in the browsercustom elements, shadow DOM, ES modules, events, classes

Because the base is standard JavaScript, what you learn in LWC transfers directly to other web work, and the other way round: our JavaScript for LWC track covers the JavaScript you'll use most.

A component in one look

Every component is a folder with an HTML template and a JavaScript class (plus optional CSS and a configuration file). Here's a complete, working component:

<!-- greetingCard.html -->
<template>
    <lightning-card title="Welcome">
        <p class="slds-p-horizontal_small">Hello, {name}! Open tasks: {openTasks}</p>
        <lightning-button label="Complete one" onclick={handleComplete}></lightning-button>
    </lightning-card>
</template>
// greetingCard.js
import { LightningElement } from 'lwc';

export default class GreetingCard extends LightningElement {
    name = 'Asha';
    openTasks = 3;

    handleComplete() {
        if (this.openTasks > 0) {
            this.openTasks--;             // changing a field re-renders the template
        }
    }
}

Result

▌Welcome
Hello, Asha! Open tasks: 3
[Complete one]

› click “Complete one”
▌Welcome
Hello, Asha! Open tasks: 2
[Complete one]

› click “Complete one”
▌Welcome
Hello, Asha! Open tasks: 1
[Complete one]

The panel shows the component as text: ▌Welcome is the card's title and [Complete one] is a button. Each click calls handleComplete, which changes openTasks; LWC notices the change and updates only the text that depends on it. No DOM code needed.

LWC vs Aura

Aura componentsLightning Web Components
Released20142019
Programming modelproprietary markup, controllers and helpersstandard JavaScript classes and HTML
Performanceheavier framework layer in the browserthin layer over native browser features – faster
Learning curveAura-specific conceptsmostly plain modern JavaScript
Todaymaintained; no new features for building UIwhere Salesforce invests – the default for new work

Both can live on the same page, and an Aura component can contain LWCs (not the other way round). In practice you'll build everything new in LWC and only touch Aura when maintaining older code.

Where LWC runs

PlaceTarget in the configuration file
Record, app and home pages in Lightning Experiencelightning__RecordPage, lightning__AppPage, lightning__HomePage
Utility bar and quick actionslightning__UtilityBar, lightning__RecordAction
Screen flowslightning__FlowScreen
Experience Cloud siteslightningCommunity__Page, lightningCommunity__Default
Salesforce mobile appsupported on record/app pages and actions

How a component works

From user action to updated screen

  1. RenderLWC creates the custom element and renders its template with the current field values
  2. Eventa click or a change runs a handler in your JavaScript class
  3. State changethe handler assigns a field (or Salesforce data arrives through @wire)
  4. Re-renderLWC updates only the parts of the DOM that use the changed fields

The core idea

A component is a JavaScript class whose fields drive an HTML template. You change data; LWC updates the screen. Everything else in this course – data from Salesforce, events between components, forms, tests – builds on that.

Practice

Try it yourself

  1. Change the greeting card so that, when the count reaches zero, the text reads "All done for today" instead.

    Show solution
    <!-- greetingCard.html -->
    <template>
        <lightning-card title="Welcome">
            <p>{message}</p>
            <lightning-button label="Complete one" onclick={handleComplete}></lightning-button>
        </lightning-card>
    </template>
    // greetingCard.js
    import { LightningElement } from 'lwc';
    
    export default class GreetingCard extends LightningElement {
        openTasks = 1;
    
        get message() {                         // a getter: recalculated on every render
            if (this.openTasks === 0) return 'All done for today';
            return `You have ${this.openTasks} open ${this.openTasks === 1 ? 'task' : 'tasks'}.`;
        }
    
        handleComplete() {
            if (this.openTasks > 0) this.openTasks--;
        }
    }

    Result

    ▌Welcome
    You have 1 open task.
    [Complete one]
    
    › click “Complete one”
    ▌Welcome
    All done for today
    [Complete one]

Quick check

What is LWC built on?

Web standards – custom elements, shadow DOM, ES modules and classes – with a thin Salesforce layer on top.

Can an LWC contain an Aura component?

No. Aura components can contain LWCs, not the other way round.

What makes a component re-render?

Changing a field that the template uses (or new data from a wire adapter).

Summary

  • LWC is Salesforce's standards-based UI framework and the default for new development.
  • A component is an HTML template plus a JavaScript class; changing fields re-renders the template.
  • Components run on Lightning pages, in flows, Experience Cloud sites and the mobile app.

Finished this lesson?

Mark it complete to track your progress, then carry on with the next lesson.

Next lesson

Search LearnFrenzy

Esc

Quick links