LWC Interview Questions
Lightning Data Service, wire adapters, performance, and component communication.
98 unique questions in this topic
Difficulty Level
Topic Focus
Showing 98 of 98 LWC questions
What is Lightning Web Components (LWC)?
Leadership wants a custom widget on the Account page. You explain why LWC is the modern choice.
What is the difference between @api and @track?
A parent passes a record Id to a child component. You explain public properties and reactivity.
How do parent and child LWCs communicate?
A child picker selects an Account and the parent list must refresh. You explain communication patterns.
What is Lightning Data Service (LDS)?
You need Account Name on a component without writing Apex. You introduce LDS.
What is @wire in LWC?
You load picklist values for an object field without Apex. You explain wire adapters.
How do you call Apex from LWC?
On button click, you submit a form that creates a Case via server logic. You outline the pattern.
What is SLDS and why use lightning-base components?
A developer builds custom HTML buttons that look wrong on Salesforce mobile. You point them to base components.
How do you deploy and test LWCs?
Your component works locally in VS Code but fails in sandbox. You describe LWC dev workflow basics.
What are lifecycle hooks in LWC?
You must load data when a component appears on a tab. You explain connectedCallback.
What is navigation in LWC?
After creating a record, you redirect user to the new record page. You mention NavigationMixin.
How does LWC handle forms and validation?
Users submit incomplete custom forms. You describe client-side validation approach.
What common LWC performance mistakes should beginners avoid?
A datatable component loads thousands of rows and freezes the browser. You list beginner performance tips.
Explain Lightning Data Service vs imperative Apex for record data
A record detail LWC fetches Account via Apex on every render while sibling components duplicate the same query causing load delays.
Design component communication patterns in LWC
Parent filter panel, data table, and summary chart on Opportunity page must stay synchronized without tight coupling.
Optimize LWC rendering performance for large data sets
Custom datatable rendering 2000 Opportunity rows freezes the browser on Account record pages.
Implement error handling and user feedback patterns in LWC
Users report silent failures when Apex throws validation errors—UI shows infinite spinner.
Architect LWC security with Locker and CSP considerations
Third-party chart library fails in LWC due to Locker Service restrictions on eval and DOM APIs.
Use wire adapters vs imperative Apex decision framework
Team debates wire(getPicklistValues) vs Apex returning picklist options for dependent picklists on custom object.
Build accessible LWCs meeting WCAG requirements
Enterprise procurement requires VPAT documentation but custom LWCs fail keyboard navigation and screen reader audits.
Design LWC for Experience Cloud and guest user contexts
Portal registration LWC works for members but guest users see insufficient privileges on same component deployed to public page.
Implement offline and resilient mobile LWC patterns
Field reps lose connectivity; mobile app LWCs show errors instead of cached read-only customer summaries.
Integrate LWC with Flow Screen components bidirectionally
Screen Flow needs custom product configurator LWC passing complex JSON selection to next Flow element.
Architect LWC testing with Jest and sfdx-lwc-jest
CI pipeline lacks LWC tests; regressions ship when wire adapters refactored.
Design reusable LWC design system for enterprise org
Twelve teams built inconsistent buttons, modals, and form layouts across 80 LWCs causing brand fragmentation.
Handle record edit forms with lightning-record-edit-form vs custom
Complex conditional field visibility requirements exceed lightning-record-edit-form capabilities.
Implement infinite scroll and lazy loading with wire adapters
Activity timeline LWC must load older tasks on scroll without reloading entire 500-item list.
Migrate Aura components to LWC strategically
Legacy org has 120 Aura components; leadership wants LWC roadmap without big-bang rewrite.
Use lightning-navigation for consistent in-app navigation
Custom LWC uses window.location breaking Salesforce mobile app navigation and console tab behavior.
Design LWC metadata and deployment for multiple targets
Same LWC deployed to record page, app page, and Experience site requires different layouts and permissions.
Implement real-time updates with Platform Events in LWC
Operations dashboard LWC must refresh case counts when high-priority cases created without polling every 30 seconds.
Optimize bundle size and static resource loading
LWC loading 2MB chart library static resource slows first paint on cellular connections.
Architect LWC localization and internationalization
Global rollout requires LWCs in 8 languages but hardcoded strings block translation workflow.
Use @api getter setter for validated public properties
Parent passes invalid status value breaking child LWC internal state.
Implement lightning-datatable inline edit with Apex save
Users edit 20 rows inline but save fires 20 separate Apex calls causing limit errors.
Design slot-based composition for flexible LWC layouts
Card component needs header footer actions slots reused across modules.
Handle @wire reactive parameter changes correctly
Filter change does not refresh wired Apex until full page reload.
Build LWC file upload with lightning-file-upload
Case attachment upload must enforce 10MB limit and virus scan trigger.
Integrate LWC with Salesforce CMS content
Marketing manages banner content in CMS displayed on Experience home LWC.
Use lightning-record-picker for lookup replacement
Custom lookup LWC reimplements search poorly; users want recent records and advanced filter.
Implement custom LWC datatable cell types safely
Custom progress bar cell type causes datatable re-render loop degrading performance.
Design LWC for Lightning App Builder admin configurability
Admins cannot toggle component features without developer deployment.
Apply CSS styling within LWC shadow DOM constraints
Team uses global CSS hacks breaking in Experience Cloud LWR sites.
Handle LWC lifecycle hooks for cleanup and initialization
Component registers interval timer but never clears causing memory leak navigating away.
Integrate third-party maps in LWC for field service
Field tech dispatch map must show routes and service appointments on record page.
Build wizard multi-step LWC with state management
Four-step onboarding wizard loses data when user navigates back and forth between steps.
Use getObjectInfo and getPicklistValues wire adapters
Hardcoded picklist values in LWC break when admin adds new values without deployment.
Design LWC analytics and instrumentation
Product team cannot measure which LWC features drive user engagement on record pages.
Implement LWC modal and focus trap patterns
Custom modal allows background scroll and loses focus causing accessibility audit failure.
Compare LWC base components vs custom HTML elements
Developers build custom checkbox inputs inconsistent with Lightning Experience styling.
Handle LWC in Lightning Out and external sites
Marketing site embeds LWC via Lightning Out but authentication session expires silently.
Optimize @wire getRelatedListRecords for related lists
Custom related list LWC slower than standard related list on LDV parent records.
Design LWC error boundary and fallback UI
One LWC JavaScript error crashes entire Lightning record page flexipage region.
Implement LWC with GraphQL wire adapter for unified queries
Record page LWC needs Account fields plus related Contacts and open Cases in one round trip.
Architect LWC CI/CD with ESLint and Prettier standards
Inconsistent LWC code styles and @lwc/lwc/no-async-operation violations reach production.
Use lightning-formatted-rich-text safely for user content
Community posts rich HTML displayed in LWC—XSS concern from malicious script tags.
Design LWC performance budget for record pages
Record page hosts 12 LWCs; Lighthouse performance score unacceptable on mobile.
Handle currency and multi-currency display in LWC
Global sales LWC shows wrong currency symbols when user currency differs from record currency.
Implement LWC quick action and action override patterns
Replace standard New Opportunity button with guided LWC quick action capturing extra fields.
Build LWC provider pattern for shared context
Nested LWCs on same page duplicate wire calls for current user permissions and record context.
Integrate Einstein features in LWC UX
Sales reps want opportunity score and recommended products embedded in custom LWC pipeline view.
Design LWC for console app workspace integration
Service console LWC opens related records in subtabs but breaks when pinned tab refreshed.
Apply progressive enhancement for LWC data loading UX
Users see blank regions for 4 seconds while wires load causing support tickets about broken page.
Handle LWC version compatibility across Salesforce releases
Spring release deprecated API breaking LWCs in production for slow-upgrade sandboxes lagging versions.
Refresh LDS cache after imperative Apex updates sibling LWCs on record page
Custom LWC saves Opportunity line items via imperative Apex but standard header and related list LWCs show stale amounts until hard refresh.
Compose multiple @wire adapters without duplicate server round trips
Record page child LWCs each wire getRecord on same Account Id causing redundant server calls and slow paint.
Implement client-side pagination with imperative Apex cursor API
Activity history LWC loads 50k Tasks on Account LDV parent. Offset pagination fails at page 200 with timeout.
Build virtual scrolling list for 5000 custom object rows in LWC
Product catalog LWC renders 5000 rows in DOM crashing mobile browsers on Experience Cloud site.
Design Lightning Message Service channel catalog for enterprise org
Forty LWCs publish to ad-hoc LMS channels named by individual developers causing collisions and orphaned subscribers.
Cache imperative Apex results in LWC with staleness tolerance policy
Dashboard LWC calls expensive Apex aggregate on every tab switch reloading same 30-day metrics unnecessarily.
Handle @wire error and loading states without blank component shell
Users report broken widgets when wire fails FLS denial—component renders empty with no message.
Test @wire adapters in Jest with emit and error simulation
LWC tests mock Apex imperatively but wire path untested causing production wire adapter regressions.
Implement dynamic component rendering with lwc:component and metadata
Admin configures record page sections mapping to different LWCs per industry vertical without code deployment.
Secure LWC against IDOR when record Id comes from URL parameter
Experience Cloud LWC reads recordId from CurrentPageReference and displays Order details. User changes URL Id to view another customer order.
Optimize mobile LWC touch targets and scroll performance on record pages
Field service LWCs fail QA on iPhone: buttons too small, momentum scroll janky with nested scroll regions.
Integrate Experience Cloud LWR site with LWC and guest-safe Apex
LWR community site LWCs call Apex returning data visible to guest on public product catalog but leak warehouse stock from internal field.
Use refreshApex and getRecordNotifyChange together after composite save
LWC saves parent Account and child Contacts via single Apex transaction. Wired getRecord updates Account but related list wire stale.
Build LMS-filter-sync pattern for Opportunity pipeline board LWCs
Filter panel, kanban board, and totals footer LWCs on same app page drift when user changes owner filter—only board updates.
Implement error boundary child LWC isolating third-party chart failures
Third-party chart static resource throws on bad data collapsing entire sales dashboard flexipage region.
Design wire cacheable Apex with server-side staleness headers
cacheable=true Apex returns product pricing stale for 24 hours after admin price update until user clears browser cache.
Paginate lightning-datatable with server-side sort and filter
Case queue datatable with 200k rows needs server sort by Priority and filter by Status without loading full dataset client-side.
Mock imperative Apex and LMS in Jest for integration test coverage
Component tests mock Apex but fail to catch LMS payload regression breaking downstream subscriber LWCs.
Handle Experience Cloud member login session expiry in embedded LWC
Community member leaves tab open overnight. Morning Apex calls return 401 and LWC shows infinite spinner.
Use getRecord with layoutTypes and modes for field-efficient LDS
getRecord with default layout pulls 80 Account fields for header LWC displaying only Name and Revenue.
Implement optimistic UI update with rollback on Apex validation failure
Task completion checkbox toggles instantly but Apex validation fails leaving checkbox checked while task still open.
Build responsive master-detail LWC layout for tablet field service
Desktop master-detail LWC unusable on tablet: master list hidden, detail panel requires horizontal scroll.
Subscribe to Platform Events in LWC with empApi reconnect handling
Operations dashboard empApi subscription silently dies after laptop network reconnect. Case counts stale until page reload.
Validate @api object props with deep clone before mutating child state
Child LWC mutates @api config object in place causing parent state corruption and subtle re-render loops.
Reduce LWC re-renders when passing large arrays to child datatable
Parent recreates 2000-row array reference every wire refresh causing child datatable full re-render and scroll position loss.
Implement field-level permission messaging when LDS wire denies field
Wire getRecord succeeds but sensitive field null for restricted user. LWC shows blank salary column without explanation.
Wire getListUi for standard list views vs custom Apex list LWC
Team builds custom Apex list LWC duplicating standard Case list view filters already defined in Salesforce list views.
Design Jest test suite for LMS-heavy navigation shell LWC
Navigation shell LWC routes LMS messages to ten child regions. Zero Jest tests; routing regression ships breaking three modules.
Load imperative Apex on user action not connectedCallback for record pages
Every record page load fires five imperative Apex calls from connectedCallback even when user never opens tabs.
Secure Experience Cloud self-registration LWC against bot submissions
Public registration LWC flooded with bot signups exhausting community licenses and polluting Lead queue.
Combine GraphQL wire with imperative Apex for unsupported UI API fields
Record header needs Account fields plus custom rollup not in GraphQL schema. Team runs three wires and two Apex calls.
Implement client-side filter on wired data without re-fetching Apex
LWC wires cacheable Apex returning 2000 products then client filters by category. Re-filter re-fetches Apex unnecessarily.
Build mobile-first quick action LWC with offline-aware save queue
Mobile quick action LWC logs field visit. Saves fail silently when technician offline losing visit data.
Audit Experience Cloud LWC for CSP and third-party script violations
Marketing embeds analytics script in LWC static resource. CSP blocks script in production LWR site breaking tracking and console errors.
Structure Apex controller layer for LWC with single responsibility methods
One @AuraEnabled god method returns header, tabs, related counts, and picklists causing heap errors and untestable LWC.