{"id":1650,"date":"2026-09-20T09:00:00","date_gmt":"2026-09-20T03:30:00","guid":{"rendered":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/"},"modified":"2026-11-15T11:32:55","modified_gmt":"2026-11-15T06:02:55","slug":"first-lightning-web-component-tutorial","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/","title":{"rendered":"First Lightning Web Component: Build, Deploy and Add It to a Page"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Your First Lightning Web Component is easier to build than most people expect. In about fifteen minutes, you can generate the files, add a text box and a button, deploy the bundle and see it working on a Lightning page. This post walks through every step, so you finish with a real component instead of just theory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, we build a small &#8220;course greeting&#8221; component for Bright Path Tutors. You will use VS Code, the Salesforce CLI and Lightning App Builder. It builds on <a href=\"https:\/\/swapnilzambare.com\/blog\/lightning-web-components-lwc-vs-aura\/\">Lightning Web Components basics<\/a>, <a href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-cli-setup-vs-code\/\">Salesforce CLI and VS Code setup<\/a> and <a href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-cli-deploy-retrieve-metadata\/\">deploying with the CLI<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a First Lightning Web Component Project?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A First Lightning Web Component project is the smallest complete LWC: one folder with an HTML template, a JavaScript class and a metadata file. It reacts to user input, so you see how data flows between the template and the class. Once you understand this loop, every bigger component follows the same pattern.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Building a First Lightning Web Component is like learning to cook with a simple omelette. It uses only a few ingredients, but it teaches heat, timing and flipping. After that, harder dishes feel familiar. This component is your omelette.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Building Your First Lightning Web Component Matters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Reading about LWC only goes so far. Here is why building your First Lightning Web Component matters.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, you learn the real folder structure of an LWC bundle.<\/li>\n\n<li>Also, you practise the deploy cycle you will use every day.<\/li>\n\n<li>Next, you see how a click changes data and the screen updates.<\/li>\n\n<li>You learn where components appear in Lightning App Builder.<\/li>\n\n<li>Finally, you get a working base to copy for later components.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So your First Lightning Web Component gives you the full development loop.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How the First Lightning Web Component Workflow Works<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The workflow has five steps. First, you generate the component bundle with the CLI or the VS Code command palette. Next, you write the template and the JavaScript class. Then you set isExposed and targets in the metadata file. After that, you deploy the folder to your org. Finally, you open Lightning App Builder, drag the component onto a page and save.<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-diagram-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-diagram-1-1024x640.png\" alt=\"First Lightning Web Component diagram showing generate, write, expose, deploy and add to page\" class=\"wp-image-1648\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-diagram-1-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-diagram-1-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-diagram-1-768x480.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">The five steps to build and place your first component.<\/figcaption><\/figure>\n\n\n<h3 class=\"wp-block-heading\">Generate the Bundle<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The command <code>sf lightning generate component<\/code> creates the folder and starter files. In VS Code, the command SFDX: Create Lightning Web Component does the same.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Write the Template<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The template shows values and listens for events, such as onchange on an input and onclick on a button.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Write the Class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The class stores data in fields and changes them in handler methods. When a field used in the template changes, LWC re-renders that part.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Expose the Component<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">isExposed true and at least one target make it appear in App Builder.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Deploy and Place<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Deploy with <code>sf project deploy start<\/code>, then place the component on a page.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Commands You Will Use<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below lists the commands for this build.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Task<\/th><th>Command or menu<\/th><\/tr><\/thead><tbody><tr><td>Create the bundle<\/td><td>sf lightning generate component &#8211;type lwc<\/td><\/tr><tr><td>Deploy one component<\/td><td>sf project deploy start &#8211;source-dir path<\/td><\/tr><tr><td>Open the org<\/td><td>sf org open<\/td><\/tr><tr><td>Add to a page<\/td><td>Setup &gt; Lightning App Builder<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Field Update vs Page Refresh<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below compares how LWC updates the screen with an old-style full page refresh.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>LWC field update<\/th><th>Full page refresh<\/th><\/tr><\/thead><tbody><tr><td>What reloads<\/td><td>Only the changed part<\/td><td>The whole page<\/td><\/tr><tr><td>Speed<\/td><td>Instant<\/td><td>Slower<\/td><\/tr><tr><td>User input kept<\/td><td>Yes<\/td><td>Often lost<\/td><\/tr><tr><td>Code needed<\/td><td>Change a class field<\/td><td>Reload or redirect<\/td><\/tr><tr><td>User experience<\/td><td>Smooth<\/td><td>Jumpy<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When to use which is clear. In LWC, you almost never refresh the page. Instead, change a field and let the framework update the screen.<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-diagram-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-diagram-2-1024x640.png\" alt=\"First Lightning Web Component diagram comparing an LWC field update with a full page refresh\" class=\"wp-image-1649\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-diagram-2-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-diagram-2-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-diagram-2-768x480.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">LWC field update vs full page refresh.<\/figcaption><\/figure>\n\n\n<h2 class=\"wp-block-heading\">A Real First Lightning Web Component Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s build the First Lightning Web Component for Bright Path Tutors. A tutor types a name, clicks a button, and sees a welcome message.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Generate the Files<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sf lightning generate component --type lwc --name courseGreeting --output-dir force-app\/main\/default\/lwc<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This creates the courseGreeting folder with an HTML file, a JavaScript file and a .js-meta.xml file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Write the Template<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;\n    &lt;lightning-card title=\"Bright Path Tutors\" icon-name=\"custom:custom63\"&gt;\n        &lt;div class=\"slds-p-around_medium\"&gt;\n            &lt;lightning-input label=\"Tutor name\" value={tutorName}\n                onchange={handleNameChange}&gt;&lt;\/lightning-input&gt;\n            &lt;lightning-button class=\"slds-m-top_small\" variant=\"brand\"\n                label=\"Say hello\" onclick={handleGreet}&gt;&lt;\/lightning-button&gt;\n            &lt;p class=\"slds-m-top_small\"&gt;{message}&lt;\/p&gt;\n        &lt;\/div&gt;\n    &lt;\/lightning-card&gt;\n&lt;\/template&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The input shows tutorName and calls handleNameChange when the text changes. Then the button calls handleGreet, and the paragraph shows the message.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Write the Class<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>import { LightningElement } from 'lwc';\n\nexport default class CourseGreeting extends LightningElement {\n    tutorName = '';\n    message = 'Type your name and click the button.';\n\n    handleNameChange(event) {\n        this.tutorName = event.target.value;\n    }\n\n    handleGreet() {\n        this.message = this.tutorName\n            ? `Welcome, ${this.tutorName}! Your courses are ready.`\n            : 'Please enter your name first.';\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">handleNameChange copies the input value into tutorName. Then handleGreet builds the message. Because message is a class field used in the template, the screen updates by itself.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Expose, Deploy and Place<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Set isExposed to true and add the lightning__AppPage and lightning__HomePage targets in courseGreeting.js-meta.xml. Then run this command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sf project deploy start --source-dir force-app\/main\/default\/lwc\/courseGreeting<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, go to Setup &gt; Lightning App Builder &gt; New &gt; App Page, drag courseGreeting from the Custom section, save and activate.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Try It<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here is what Asha Mehta sees after typing her name and clicking the button.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Welcome, Asha! Your courses are ready.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The message changes instantly, with no page reload, so your First Lightning Web Component works.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">First Lightning Web Component Naming Rules<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Folder and file names use camelCase, such as courseGreeting. In markup, the same component becomes c-course-greeting. Names must start with a lowercase letter and cannot contain hyphens or double underscores.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Your First Lightning Web Component<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Forgetting isExposed, so the component is missing in App Builder.<\/li>\n\n<li>Naming the folder and files differently.<\/li>\n\n<li>Changing a field outside the class and expecting the screen to update.<\/li>\n\n<li>Using a hyphen or capital letter at the start of the folder name.<\/li>\n\n<li>Deploying the whole project when only one component changed.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Your First Lightning Web Component<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Generate bundles with the CLI so names stay consistent.<\/li>\n\n<li>Use base components such as lightning-input and lightning-button.<\/li>\n\n<li>Keep handlers short, with one job each.<\/li>\n\n<li>Deploy only the folder you changed while learning.<\/li>\n\n<li>Commit your work to Git after each working step.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add a second button called Clear that resets tutorName and message. Hint: create a handleClear method that sets both fields back to their starting values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Most Asked Interview Questions on Your First Lightning Web Component<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Beginner LWC questions often follow this exact build. Here are the 21 questions asked most about building your First Lightning Web Component.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Basic Questions on Your First Lightning Web Component<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: How do you create an LWC from the CLI?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run sf lightning generate component with &#8211;type lwc and a component name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: Which files does the generator create?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It creates an HTML file, a JavaScript file and a .js-meta.xml file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: How do you handle a button click?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Add onclick={handlerName} on the button, then write that method in the class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: How do you read the value of an input?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use event.target.value inside the change handler.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: How does the screen update after a change?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">LWC re-renders automatically when a field used in the template changes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6: How do you make the component appear in App Builder?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Set isExposed to true and add targets in the metadata file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7: How do you deploy one component?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use sf project deploy start with &#8211;source-dir pointing to the component folder.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code and Scenario Questions on Your First Lightning Web Component<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8: What is the markup name for courseGreeting?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is c-course-greeting, because markup uses kebab case.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q9: Can a folder name start with a capital letter?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No, because component names must start with a lowercase letter.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q10: Why use lightning-input instead of a plain input?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because it gives the Salesforce look, labels and accessibility for free.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q11: Where do you add the component to a page?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In Lightning App Builder, from the Custom section of the components panel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q12: What is event.target?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is the element that fired the event, such as the input box.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q13: How do you show a message only when it exists?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use a conditional directive such as lwc:if, which the next post covers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q14: What is the role of apiVersion in the metadata file?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It sets which Salesforce API version the component uses for its behaviour.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced Questions on Your First Lightning Web Component<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q15: Why use template literals for the message?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because they make it easy to insert values into strings with ${&#8230;}.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q16: Do you need @track for simple fields?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No, because all class fields are reactive for reassignment since Spring &#8217;20.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q17: How do you test the component quickly without deploying?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use Jest unit tests locally, which a later post covers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q18: Why deploy only one folder while learning?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because it is faster and avoids errors from unrelated files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q19: Can the same component appear on record and home pages?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, so long as the metadata file lists both targets.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q20: What is the first thing to check when a component does not appear?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First check isExposed and the targets, then check the deployment result.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q21: How would you extend this component?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, add Apex or Lightning Data Service to load real course data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/platform\/lwc\/guide\/get-started-lwc.html\" target=\"_blank\" rel=\"noopener noreferrer\">Get Started with Lightning Web Components (LWC Developer Guide)<\/a><\/li>\n\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/platform\/lwc\/guide\/get-started-best-practices.html\" target=\"_blank\" rel=\"noopener noreferrer\">LWC Best Practices (LWC Developer Guide)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Your First Lightning Web Component needs HTML, JavaScript and metadata files.<\/li>\n\n<li>Generate bundles with sf lightning generate component.<\/li>\n\n<li>Event handlers change class fields, and the screen updates by itself.<\/li>\n\n<li>isExposed and targets control App Builder visibility.<\/li>\n\n<li>Deploy one folder at a time while learning.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Next, learn how values, getters and conditions shape the template in our guide to <a href=\"https:\/\/swapnilzambare.com\/blog\/lwc-data-binding-getters-conditional-rendering\/\">LWC data binding, getters and conditional rendering<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Your First Lightning Web Component is easier to build than most people expect. In about fifteen minutes, you can generate the files, add a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1647,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[245,8,96],"tags":[130,26,113],"swapz_series":[],"class_list":["post-1650","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lightning-web-components","category-salesforce","category-salesforce-developer","tag-devops","tag-intermediate","tag-lwc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>First Lightning Web Component: Step-by-Step Build<\/title>\n<meta name=\"description\" content=\"First Lightning Web Component tutorial: generate the bundle, write HTML and JavaScript, handle a click, deploy with the CLI and 21 interview Q&amp;A.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"First Lightning Web Component: Step-by-Step Build\" \/>\n<meta property=\"og:description\" content=\"First Lightning Web Component tutorial: generate the bundle, write HTML and JavaScript, handle a click, deploy with the CLI and 21 interview Q&amp;A.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil Zambare - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-20T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-15T06:02:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil Zambare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil Zambare\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/\"},\"author\":{\"name\":\"Swapnil Zambare\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/10b09224c8bcc562716e86789427592a\"},\"headline\":\"First Lightning Web Component: Build, Deploy and Add It to a Page\",\"datePublished\":\"2026-09-20T03:30:00+00:00\",\"dateModified\":\"2026-11-15T06:02:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/\"},\"wordCount\":1556,\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/first-lightning-web-component-tutorial-featured.png\",\"keywords\":[\"DevOps\",\"Intermediate\",\"LWC\"],\"articleSection\":[\"Lightning Web Components\",\"Salesforce\",\"Salesforce Developer\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/\",\"name\":\"First Lightning Web Component: Step-by-Step Build\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/first-lightning-web-component-tutorial-featured.png\",\"datePublished\":\"2026-09-20T03:30:00+00:00\",\"dateModified\":\"2026-11-15T06:02:55+00:00\",\"description\":\"First Lightning Web Component tutorial: generate the bundle, write HTML and JavaScript, handle a click, deploy with the CLI and 21 interview Q&A.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/#primaryimage\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/first-lightning-web-component-tutorial-featured.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/first-lightning-web-component-tutorial-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"First Lightning Web Component featured image: title card with an LWC code example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/first-lightning-web-component-tutorial\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"First Lightning Web Component: Build, Deploy and Add It to a Page\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"name\":\"Swapnil Zambare - Blog\",\"description\":\"Salesforce &amp; Tech Guides\",\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\",\"name\":\"Swapnil Zambare - Blog\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"width\":512,\"height\":512,\"caption\":\"Swapnil Zambare - Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/theSwapnilZambare\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/10b09224c8bcc562716e86789427592a\",\"name\":\"Swapnil Zambare\",\"sameAs\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\"],\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/author\\\/swapnil-zambare\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"First Lightning Web Component: Step-by-Step Build","description":"First Lightning Web Component tutorial: generate the bundle, write HTML and JavaScript, handle a click, deploy with the CLI and 21 interview Q&A.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"First Lightning Web Component: Step-by-Step Build","og_description":"First Lightning Web Component tutorial: generate the bundle, write HTML and JavaScript, handle a click, deploy with the CLI and 21 interview Q&A.","og_url":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/","og_site_name":"Swapnil Zambare - Blog","article_published_time":"2026-09-20T03:30:00+00:00","article_modified_time":"2026-11-15T06:02:55+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-featured.png","type":"image\/png"}],"author":"Swapnil Zambare","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Swapnil Zambare","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/#article","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/"},"author":{"name":"Swapnil Zambare","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/10b09224c8bcc562716e86789427592a"},"headline":"First Lightning Web Component: Build, Deploy and Add It to a Page","datePublished":"2026-09-20T03:30:00+00:00","dateModified":"2026-11-15T06:02:55+00:00","mainEntityOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/"},"wordCount":1556,"publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-featured.png","keywords":["DevOps","Intermediate","LWC"],"articleSection":["Lightning Web Components","Salesforce","Salesforce Developer"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/","url":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/","name":"First Lightning Web Component: Step-by-Step Build","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-featured.png","datePublished":"2026-09-20T03:30:00+00:00","dateModified":"2026-11-15T06:02:55+00:00","description":"First Lightning Web Component tutorial: generate the bundle, write HTML and JavaScript, handle a click, deploy with the CLI and 21 interview Q&A.","breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-featured.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/first-lightning-web-component-tutorial-featured.png","width":2400,"height":1260,"caption":"First Lightning Web Component featured image: title card with an LWC code example"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/first-lightning-web-component-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"First Lightning Web Component: Build, Deploy and Add It to a Page"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil Zambare - Blog","description":"Salesforce &amp; Tech Guides","publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/swapnilzambare.com\/blog\/#organization","name":"Swapnil Zambare - Blog","url":"https:\/\/swapnilzambare.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","width":512,"height":512,"caption":"Swapnil Zambare - Blog"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/theSwapnilZambare"]},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/10b09224c8bcc562716e86789427592a","name":"Swapnil Zambare","sameAs":["https:\/\/swapnilzambare.com\/blog"],"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=1650"}],"version-history":[{"count":1,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1650\/revisions"}],"predecessor-version":[{"id":2314,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1650\/revisions\/2314"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/1647"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=1650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=1650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=1650"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=1650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}