Here are commonly asked Lightning Web Components interview questions, with concise, accurate answers.
Fundamentals
Q1: What is Lightning Web Components (LWC)? LWC is a UI framework for building components on the Salesforce platform using modern JavaScript web standards (Web Components, ES6+), rather than Salesforce's older, proprietary Aura framework.
Q2: What's the difference between LWC and Aura components? LWC is built on native Web Components standards and is generally lighter and faster than Aura. LWC and Aura components can coexist and even be nested (an LWC can go inside an Aura component, though not vice versa in most cases), which is why many orgs migrate gradually rather than all at once.
Q3: What are the lifecycle hooks in LWC?
The main ones are constructor(), connectedCallback(), renderedCallback(), and disconnectedCallback() — covering component creation, insertion into the DOM, post-render logic, and cleanup on removal.
Data & Reactivity
Q4: What does the @track decorator do, and is it still needed for every property?
@track marks a property as reactive so the component re-renders when it changes. In modern LWC, simple property reassignment is reactive by default — @track is mainly needed for reactivity on mutations within objects or arrays (e.g., pushing to an array or changing a nested field).
Q5: What's the difference between @api, @track, and @wire?
@apiexposes a property or method publicly, so a parent component can set it.@track(see above) marks internal reactive state.@wireconnects a component to a Salesforce data source (an Apex method or a Lightning Data Service wire adapter) reactively.
Q6: What is Lightning Data Service (LDS), and why use it over calling Apex directly? LDS lets components read/write record data without writing Apex, benefiting from shared caching, automatic UI updates when records change, and automatic security enforcement — reducing both code and server calls.
Component Communication
Q7: How does a parent component pass data to a child?
Via public properties (@api) set as HTML attributes in the parent's template.
Q8: How does a child component communicate with its parent?
By dispatching custom events (this.dispatchEvent(new CustomEvent(...))), which the parent listens for in its template.
Q9: How do unrelated (sibling) components communicate? Typically via a Lightning Message Service (LMS) for cross-component/cross-DOM communication, since LWC intentionally doesn't support arbitrary global pub-sub like Aura's application event bus did by default.
Calling Apex
Q10: What's the difference between calling Apex imperatively vs. with @wire?
@wire calls are reactive and cached — they re-run automatically when their reactive parameters change, and Lightning Data Service/UI API leverages the same caching layer. Imperative calls (await getData()) run on demand — useful for actions triggered by user events like button clicks, where you don't want an automatic re-fetch.
Q11: How do you handle errors from a wired or imperative Apex call?
For @wire, handle the error property returned alongside data. For imperative calls, wrap the call in a try/catch and surface errors via a toast or inline message — never let an unhandled promise rejection fail silently.
Performance & Best Practices
Q12: How do you avoid unnecessary re-renders in LWC?
Keep reactive properties minimal and scoped, avoid deeply nested reactive objects where possible, and use renderedCallback() sparingly (it runs on every re-render, so heavy logic there hurts performance).
Q13: What is the Lightning Locker / Lightning Web Security (LWS)? A security architecture that isolates each component's JavaScript context, enforcing strict DOM access rules to prevent cross-component and cross-namespace vulnerabilities — one reason LWC can't do certain raw DOM manipulations that plain JavaScript otherwise allows.
Preparing Further
These cover the most common conceptual ground, but real interviews often add a live coding round. For a structured path through LWC (and the Apex fundamentals it depends on), see our Salesforce Developer Training course, which includes technical mock interviews.