Salesforce Decode
Salesforcedecode
All interview topics

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

Beginnerlwcbasicslightning

What is Lightning Web Components (LWC)?

Leadership wants a custom widget on the Account page. You explain why LWC is the modern choice.

Beginnerapitrackreactivity

What is the difference between @api and @track?

A parent passes a record Id to a child component. You explain public properties and reactivity.

Beginnereventscommunication

How do parent and child LWCs communicate?

A child picker selects an Account and the parent list must refresh. You explain communication patterns.

Beginnerldswireui-record-api

What is Lightning Data Service (LDS)?

You need Account Name on a component without writing Apex. You introduce LDS.

Beginnerwireadapters

What is @wire in LWC?

You load picklist values for an object field without Apex. You explain wire adapters.

Beginnerapeximperative

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.

Beginnersldsbase-componentsui

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.

Beginnerdeploymenttestingjest

How do you deploy and test LWCs?

Your component works locally in VS Code but fails in sandbox. You describe LWC dev workflow basics.

BeginnerlifecycleconnectedCallback

What are lifecycle hooks in LWC?

You must load data when a component appears on a tab. You explain connectedCallback.

Beginnernavigationlightning-navigation

What is navigation in LWC?

After creating a record, you redirect user to the new record page. You mention NavigationMixin.

Beginnerformsvalidation

How does LWC handle forms and validation?

Users submit incomplete custom forms. You describe client-side validation approach.

Beginnerperformancebest-practices

What common LWC performance mistakes should beginners avoid?

A datatable component loads thousands of rows and freezes the browser. You list beginner performance tips.

Intermediateldswireperformance

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.

Intermediateeventscommunicationarchitecture

Design component communication patterns in LWC

Parent filter panel, data table, and summary chart on Opportunity page must stay synchronized without tight coupling.

Advancedperformancevirtualizationrendering

Optimize LWC rendering performance for large data sets

Custom datatable rendering 2000 Opportunity rows freezes the browser on Account record pages.

Intermediateerror-handlinguxtoast

Implement error handling and user feedback patterns in LWC

Users report silent failures when Apex throws validation errors—UI shows infinite spinner.

Advancedsecuritylockercsp

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.

Intermediatewireimperativepatterns

Use wire adapters vs imperative Apex decision framework

Team debates wire(getPicklistValues) vs Apex returning picklist options for dependent picklists on custom object.

Advancedaccessibilitywcaga11y

Build accessible LWCs meeting WCAG requirements

Enterprise procurement requires VPAT documentation but custom LWCs fail keyboard navigation and screen reader audits.

Advancedexperience-cloudguestcommunity

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.

Advancedmobileofflinesalesforce-mobile

Implement offline and resilient mobile LWC patterns

Field reps lose connectivity; mobile app LWCs show errors instead of cached read-only customer summaries.

Intermediateflowscreen-flowintegration

Integrate LWC with Flow Screen components bidirectionally

Screen Flow needs custom product configurator LWC passing complex JSON selection to next Flow element.

Intermediatejesttestingunit-tests

Architect LWC testing with Jest and sfdx-lwc-jest

CI pipeline lacks LWC tests; regressions ship when wire adapters refactored.

Architectdesign-systemreusabilityslds

Design reusable LWC design system for enterprise org

Twelve teams built inconsistent buttons, modals, and form layouts across 80 LWCs causing brand fragmentation.

Intermediaterecord-formdmlui-api

Handle record edit forms with lightning-record-edit-form vs custom

Complex conditional field visibility requirements exceed lightning-record-edit-form capabilities.

Advancedinfinite-scrollpaginationwire

Implement infinite scroll and lazy loading with wire adapters

Activity timeline LWC must load older tasks on scroll without reloading entire 500-item list.

Advancedmigrationauracoexistence

Migrate Aura components to LWC strategically

Legacy org has 120 Aura components; leadership wants LWC roadmap without big-bang rewrite.

Intermediatenavigationexperiencerouting

Use lightning-navigation for consistent in-app navigation

Custom LWC uses window.location breaking Salesforce mobile app navigation and console tab behavior.

Intermediatemetadatadeploymenttargets

Design LWC metadata and deployment for multiple targets

Same LWC deployed to record page, app page, and Experience site requires different layouts and permissions.

Advancedplatform-eventsemp-apireal-time

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.

Intermediatebundle-sizestatic-resourcesperformance

Optimize bundle size and static resource loading

LWC loading 2MB chart library static resource slows first paint on cellular connections.

Intermediatei18nlocalizationcustom-labels

Architect LWC localization and internationalization

Global rollout requires LWCs in 8 languages but hardcoded strings block translation workflow.

Intermediateapiproperties

Use @api getter setter for validated public properties

Parent passes invalid status value breaking child LWC internal state.

Advanceddatatableinline-edit

Implement lightning-datatable inline edit with Apex save

Users edit 20 rows inline but save fires 20 separate Apex calls causing limit errors.

Intermediateslotscomposition

Design slot-based composition for flexible LWC layouts

Card component needs header footer actions slots reused across modules.

Intermediatewirereactivity

Handle @wire reactive parameter changes correctly

Filter change does not refresh wired Apex until full page reload.

Intermediatefilesupload

Build LWC file upload with lightning-file-upload

Case attachment upload must enforce 10MB limit and virus scan trigger.

Intermediatecmscontentexperience

Integrate LWC with Salesforce CMS content

Marketing manages banner content in CMS displayed on Experience home LWC.

Beginnerrecord-pickerlookup

Use lightning-record-picker for lookup replacement

Custom lookup LWC reimplements search poorly; users want recent records and advanced filter.

Advanceddatatablecustom-types

Implement custom LWC datatable cell types safely

Custom progress bar cell type causes datatable re-render loop degrading performance.

Intermediateapp-builderdesign-attributes

Design LWC for Lightning App Builder admin configurability

Admins cannot toggle component features without developer deployment.

Intermediatecssstylingslds

Apply CSS styling within LWC shadow DOM constraints

Team uses global CSS hacks breaking in Experience Cloud LWR sites.

Intermediatelifecyclehooks

Handle LWC lifecycle hooks for cleanup and initialization

Component registers interval timer but never clears causing memory leak navigating away.

Advancedmapsfield-serviceintegration

Integrate third-party maps in LWC for field service

Field tech dispatch map must show routes and service appointments on record page.

Intermediatewizardstateux

Build wizard multi-step LWC with state management

Four-step onboarding wizard loses data when user navigates back and forth between steps.

Intermediateschemapicklistwire

Use getObjectInfo and getPicklistValues wire adapters

Hardcoded picklist values in LWC break when admin adds new values without deployment.

Intermediateanalyticstelemetryinstrumentation

Design LWC analytics and instrumentation

Product team cannot measure which LWC features drive user engagement on record pages.

Intermediatemodaluxa11y

Implement LWC modal and focus trap patterns

Custom modal allows background scroll and loses focus causing accessibility audit failure.

Beginnerbase-componentshtml

Compare LWC base components vs custom HTML elements

Developers build custom checkbox inputs inconsistent with Lightning Experience styling.

Advancedlightning-outembedding

Handle LWC in Lightning Out and external sites

Marketing site embeds LWC via Lightning Out but authentication session expires silently.

Advancedrelated-listwire

Optimize @wire getRelatedListRecords for related lists

Custom related list LWC slower than standard related list on LDV parent records.

Intermediateerrorsresilience

Design LWC error boundary and fallback UI

One LWC JavaScript error crashes entire Lightning record page flexipage region.

Advancedgraphqlwireui-api

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.

Intermediateeslintcicdquality

Architect LWC CI/CD with ESLint and Prettier standards

Inconsistent LWC code styles and @lwc/lwc/no-async-operation violations reach production.

Intermediaterich-textxsssecurity

Use lightning-formatted-rich-text safely for user content

Community posts rich HTML displayed in LWC—XSS concern from malicious script tags.

Architectperformancebudgetrecord-page

Design LWC performance budget for record pages

Record page hosts 12 LWCs; Lighthouse performance score unacceptable on mobile.

Intermediatemulti-currencyformatting

Handle currency and multi-currency display in LWC

Global sales LWC shows wrong currency symbols when user currency differs from record currency.

Intermediatequick-actionactions

Implement LWC quick action and action override patterns

Replace standard New Opportunity button with guided LWC quick action capturing extra fields.

Advancedprovidercontextpatterns

Build LWC provider pattern for shared context

Nested LWCs on same page duplicate wire calls for current user permissions and record context.

Advancedeinsteinaipredictions

Integrate Einstein features in LWC UX

Sales reps want opportunity score and recommended products embedded in custom LWC pipeline view.

Intermediateconsoleworkspaceservice-cloud

Design LWC for console app workspace integration

Service console LWC opens related records in subtabs but breaks when pinned tab refreshed.

Intermediateuxloadingskeleton

Apply progressive enhancement for LWC data loading UX

Users see blank regions for 4 seconds while wires load causing support tickets about broken page.

Intermediatereleasescompatibility

Handle LWC version compatibility across Salesforce releases

Spring release deprecated API breaking LWCs in production for slow-upgrade sandboxes lagging versions.

Intermediateldscacheimperative

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.

Intermediatewireldsperformance

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.

Advancedpaginationimperativeperformance

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.

Advancedvirtual-scrollingperformancerendering

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.

Intermediatelmscommunicationarchitecture

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.

Intermediatecachingimperativeperformance

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.

Intermediatewireerror-handlingux

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.

Intermediatejestwiretesting

Test @wire adapters in Jest with emit and error simulation

LWC tests mock Apex imperatively but wire path untested causing production wire adapter regressions.

Advanceddynamic-componentsmetadataarchitecture

Implement dynamic component rendering with lwc:component and metadata

Admin configures record page sections mapping to different LWCs per industry vertical without code deployment.

Advancedsecurityexperience-cloudlds

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.

Intermediatemobileperformanceux

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.

Advancedexperience-cloudlwrsecurity

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.

Intermediateldswireimperative

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.

Intermediatelmscommunicationux

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.

Intermediateerror-handlingdynamic-componentsresilience

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.

Advancedwirecachingapex

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.

Advancedpaginationdatatableimperative

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.

Intermediatejesttestinglms

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.

Intermediateexperience-cloudsecurityerror-handling

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.

Intermediateldswireperformance

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.

Advancedimperativeerror-handlingux

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.

Intermediatemobileuxdynamic-components

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.

Advancedwirereal-timeerror-handling

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.

Intermediateapisecurityerror-handling

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.

Advancedperformancerenderingdatatable

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.

Intermediateldssecurityerror-handling

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.

Intermediatewireldsperformance

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.

Intermediatejestlmstesting

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.

Beginnerimperativeperformancelds

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.

Advancedexperience-cloudsecurityerror-handling

Secure Experience Cloud self-registration LWC against bot submissions

Public registration LWC flooded with bot signups exhausting community licenses and polluting Lead queue.

Advancedwireimperativelds

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.

Intermediatewirecachingperformance

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.

Advancedmobileimperativeerror-handling

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.

Intermediateexperience-cloudsecuritycsp

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.

Intermediateimperativearchitecturetesting

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.

LWC Interview Questions | Salesforce Decode | Salesforce Decode