LWC @wire interview questions
Most LWC data questions come down to one choice: wire it or call it imperatively. These answers explain when each is right and how caching changes the picture.
On this page (6 sections)
Interview questionsCommon MistakesRelated LWC Wire Interview QuestionsFrequently Asked Questions about LWC Wire InterviewsRelated CertificationsRelated ResourcesNew to this topic? Learn Lightning Web Components step by step before you practise.
@wire is what makes LWC reactive and elegant, but it confuses many candidates because of caching, reactive params, and refresh patterns. Here's how to talk about it like a pro.
01What is @wire and when do you use it?
What is @wire and when do you use it?
@wire is the declarative way to call Apex or Lightning Data Service from LWC. The framework calls your method automatically, manages caching, and re-invokes it when reactive parameters change. Use it for read-only data fetching where you want automatic re-fetching.
02@wire vs imperative Apex: when to use which?
@wire vs imperative Apex: when to use which?
Use @wire for data that loads with the component and reacts to property changes (record details, dropdown options). Use imperative for user-triggered actions (save button, custom search) where you need to handle promises explicitly with try/catch.
03How do reactive parameters work in @wire?
How do reactive parameters work in @wire?
Prefix parameter names with $, like @wire(getContact, { accountId: '$recordId' }). When recordId changes, wire re-invokes the Apex method with the new value. Without $, the parameter is treated as static.
04What's the structure of wire response?
What's the structure of wire response?
{ data, error } object. Always check both: if data is defined, use it; if error is defined, show an error UI. Salesforce updates this object reactively whenever the wire refreshes.
05What does @wire cache?
What does @wire cache?
Lightning Data Service automatically caches getRecord, getRecordUi etc. Apex wires are cached when the method is annotated @AuraEnabled(cacheable=true). Cache is per browser session per parameter combination.
06How do you force a wire to refresh?
How do you force a wire to refresh?
Use refreshApex(this.wiredResult). Save the wired result by capturing it in a method form: @wire(getContacts) wiredContacts; → wiredContacts.data and wiredContacts.error. Then refreshApex(this.wiredContacts) re-runs the query.
07When should @AuraEnabled have cacheable=true?
When should @AuraEnabled have cacheable=true?
When the method is read-only and safe to cache (no side effects, returns same data for same input). Cacheable methods can be wired and respect the LDS cache. Without it, the method can only be called imperatively.
08Common wire method bugs?
Common wire method bugs?
Forgetting $ on reactive params (param never updates), forgetting cacheable=true (method not wireable), not handling error path (component shows blank), and trying to mutate wired data directly (it's immutable: copy first).
09Can you wire a Lightning Data Service method like getRecord?
Can you wire a Lightning Data Service method like getRecord?
Yes. That's actually the recommended way to read records. @wire(getRecord, { recordId: '$recordId', fields: ['Account.Name'] }). Faster than Apex and uses LDS cache.
10How do you handle errors from wire?
How do you handle errors from wire?
In your wire callback or via { data, error } property pattern, check error and use a reduceErrors utility (Salesforce sample code) to extract a readable message. Show it in the UI via lightning-icon + text or use the toast service.
Common Mistakes
Missing $ on reactive params. Param never updates the wire.
Forgetting cacheable=true. Method not wireable.
Mutating wired data. It's immutable: copy first.
Frequently Asked Questions about LWC Wire Interviews
Can a wired method be called imperatively?
No, a method is either @wire-callable (cacheable=true) or imperative-callable but the same method can be both: Salesforce permits both invocation styles on cacheable methods.
Does wire work in connectedCallback?
Wire fires automatically; you don't call it. Just declare it as a class property.
Can I wire to a getter?
Yes: @wire on a method or function form, with parameters from getters returning reactive values.
What happens if reactive parameter is undefined?
Wire holds and doesn't call the method until the parameter has a value.
Difference between getRecord and getFieldValue?
getRecord wires the record, getFieldValue is a helper to safely extract a field value from the wired record object.
Related Certifications
JavaScript Developer I and PD2. See certification guides.