0% found this document useful (0 votes)
43 views3 pages

LWC in Salesforce

Lightning Web Components (LWC) is a modern UI framework for building scalable applications in Salesforce, utilizing web standards like ES6 and Shadow DOM. Key features include a component-based architecture, enhanced security, and seamless integration with Salesforce data. LWC components consist of HTML, JavaScript, and metadata files, and support advanced concepts like lifecycle hooks and event handling.

Uploaded by

Roy Harper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views3 pages

LWC in Salesforce

Lightning Web Components (LWC) is a modern UI framework for building scalable applications in Salesforce, utilizing web standards like ES6 and Shadow DOM. Key features include a component-based architecture, enhanced security, and seamless integration with Salesforce data. LWC components consist of HTML, JavaScript, and metadata files, and support advanced concepts like lifecycle hooks and event handling.

Uploaded by

Roy Harper
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Lightning Web Components (LWC) in Salesforce

Introduction

Lightning Web Components (LWC) is a modern UI framework used to build scalable and high-
performance applications in Salesforce. It leverages modern web standards like ES6, Web
Components, and Shadow DOM to create reusable components.

Key Features

 Standard Web Technologies: Uses HTML, JavaScript, and CSS.

 Lightweight and Efficient: Faster performance compared to Aura components.

 Component-Based Architecture: Encourages reusability and modular development.

 Enhanced Security: Uses Lightning Locker for secure execution.

 Seamless Data Binding: Integrates effortlessly with Salesforce data.

Structure of an LWC Component

An LWC component consists of the following files:

1. HTML File (.html) - Defines the component’s UI.

2. JavaScript File (.js) - Contains the component’s logic.

3. Metadata Configuration File (.xml) - Specifies component properties and permissions.

Example: Basic LWC Component

HTML (helloWorld.html):

<template>

<lightning-card title="Hello LWC!">

<p>{greeting}</p>

<lightning-button label="Change Greeting" onclick={changeGreeting}></lightning-button>

</lightning-card>

</template>

JavaScript (helloWorld.js):

import { LightningElement } from 'lwc';

export default class HelloWorld extends LightningElement {

greeting = 'Welcome to LWC!';

changeGreeting() {

this.greeting = 'Hello, Salesforce Developer!';

}
}

XML (helloWorld.js-meta.xml):

<?xml version="1.0" encoding="UTF-8"?>

<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"
fqn="HelloWorld">

<apiVersion>58.0</apiVersion>

<isExposed>true</isExposed>

<targets>

<target>lightning__RecordPage</target>

<target>lightning__AppPage</target>

</targets>

</LightningComponentBundle>

Working with Salesforce Data

LWC allows easy integration with Salesforce data using Apex and wire services.

Fetch Data Using @wire

import { LightningElement, wire } from 'lwc';

import getAccounts from '@salesforce/apex/AccountController.getAccounts';

export default class AccountList extends LightningElement {

@wire(getAccounts) accounts;

Advanced Concepts

 LWC Lifecycle Hooks: Methods like connectedCallback() and disconnectedCallback()


manage component behavior.

 Event Handling: Uses dispatchEvent to communicate between components.

 CSS Styling: Supports both global and scoped styles.

 Integration with Apex: Enables fetching and manipulating Salesforce data.

 Lightning Data Service (LDS): Provides declarative data access without Apex.

Conclusion

Lightning Web Components offer a modern, efficient, and scalable way to build applications in
Salesforce. With its standard web technologies, secure execution, and seamless Salesforce
integration, LWC is the preferred choice for building Lightning applications.

You might also like