LWC Communication Interview Questions: Events and LMS

LWC Communication Interview Questions with answers on custom events, parent to child calls, Lightning Message Service, pubsub and real component scenarios.

Updated 18 min read
LWC Communication Interview Questions featured image with sample question cards

LWC Communication Interview Questions are a favourite because the answer depends entirely on where the two components sit. Parent and child is one answer, two unrelated components on a page is another, and candidates who give one answer for both get caught.

Last reviewed for the Winter ’27 release (November 2026).

This post covers the questions interviewers ask, grouped into parent to child, child to parent, siblings and the message service, event options, and scenario questions where a message never arrives.

LWC Communication Interview Questions diagram showing the four communication paths

Caption: The relationship between the two components decides which path you use.

What LWC Communication Interview Questions Cover

LWC Communication Interview Questions test one rule above all. Data flows down through properties, and notifications flow up through events.

Think of it like a company. Where the parent reads a child property, the patterns in parent to child communication apply. Instructions go down the structure, and reports come back up, and two people in different departments go through a shared channel rather than shouting across the building.

That rule is what LWC Communication Interview Questions are testing, because it keeps components reusable. A child that changes its parent’s data directly cannot be dropped anywhere else.

The Four Paths

RelationshipHow they talk
Parent to childA public property, or a public method
Child to parentA custom event the parent handles
Sibling to siblingThrough the shared parent
Anywhere to anywhereLightning Message Service on a channel

That table answers most LWC Communication Interview Questions. The interesting follow up is always why a child should not reach into a parent.

// child
handleSelect() {
  this.dispatchEvent(new CustomEvent('courseselect', {
    detail: { courseId: this.courseId, fee: this.fee }
  }));
}
<!-- parent -->
<template>
  <c-course-card
    course-id={courseId}
    oncourseselect={handleCourseSelect}>
  </c-course-card>
</template>

Three details there come up in LWC Communication Interview Questions. The event name is lowercase with no hyphens, the data travels in detail, and the parent handler name is prefixed with on.

Custom Events vs Lightning Message Service

LWC Communication Interview Questions comparison of custom events and message service

Caption: Events need a parent listening, and the message service needs neither side to know the other.

NeedPick
A child telling its parent a row was pickedCustom event
A parent refreshing a childA public method on the child
Two components in different regions of a pageLightning Message Service
An LWC talking to an Aura componentLightning Message Service
A component inside a Visualforce pageLightning Message Service
Siblings under the same parentAn event up, then a property down

LWC Communication Interview Questions usually describe two components and ask which row fits.

The posts on custom events and Lightning Message Service cover both in depth.

LWC Communication Interview Questions on Parent to Child

Q1: How does a parent pass data to a child?

Through a public property, declared with @api in the child.

Example: the child has @api courseId; and the parent writes <c-course-card course-id={selectedId}></c-course-card>. When selectedId changes, the child gets the new value.

Interview tip: name kebab case in the same breath. It is a frequent follow up.

Q2: How is that property written in markup?

In kebab case, so courseId becomes course-id.

HTML attributes are not case sensitive, so LWC maps camelCase property names to lowercase words joined by hyphens.

Follow-up you may get: What about a property named URL? It becomes u-r-l, so avoid all caps names.

Q3: How does a parent call a method on a child?

Get a reference to the child, then call a method marked with @api.

Example: in the child, @api reset() { this.value = ”; }; in the parent, this.refs.courseForm.reset();

Interview tip: give a real use, like validate() on a child form.

Q4: How do you get that reference?

With this.refs when the child has lwc:ref, or with this.template.querySelector.

Example: <c-course-form lwc:ref=”courseForm”> then this.refs.courseForm. refs is simpler and does not depend on CSS selectors.

Q5: Which is more stable, a ref or a class selector?

A ref, because class names often change during styling work.

A selector like .course-form breaks silently if someone renames the class; lwc:ref names exist only for code.

Q6: Should a parent reach into a child’s internals?

No. Only its public properties and methods are part of the contract.

Reaching into a child’s DOM or private fields ties the parent to details that can change, and shadow DOM blocks most of it anyway.

Q7: Can a public method return a value?

Yes, which suits a validate method that returns true or false.

Example: @api validate() { return […this.template.querySelectorAll(‘lightning-input’)].every(i => i.reportValidity()); }

Follow-up you may get: Can a public method be async? Yes, the parent then awaits the returned promise.

Q8: What is a common use of a public method?

Asking a child form to validate itself, reset itself or focus a field.

These are commands the parent gives at a specific moment, which properties cannot express well.

Q9: Does setting a public property re-render the child?

Yes, when the value changes, the child re-renders with it.

Setting the same value again does not cause a re-render.

Q10: What happens if the child mutates that property?

It breaks the one way data flow, and the parent’s value will overwrite it on the next render.

LWC also warns about it in development. Copy the value into a private field if the child needs to edit it.

Interview tip: say you copy @api values into private fields when the child must edit them.

Q11: How should the child request a change instead?

By firing an event that the parent handles.

Example: this.dispatchEvent(new CustomEvent(‘levelchange’, { detail: { level: ‘Advanced’ } })); and the parent updates its own field.

Q12: Can a public property be an object?

Yes, and the child should treat it as read only.

LWC freezes objects passed through @api, so changing them inside the child throws an error. Make a copy with { …this.course } if you need to edit.

Q13: How do you pass a record from a parent to a child safely?

Pass the record or just its ID through an @api property, and let the child read it without changing it. If the child needs fresh data, pass the ID and let it wire getRecord itself, so the child stays independent.

Q14: Can a child call a parent’s method directly?

No. A child does not know its parent and should not depend on it. It fires an event, and the parent decides what to do, which keeps the child reusable in other places.

Q15: Why use a getter and setter pair on a public property?

To derive something when the value arrives, rather than recomputing on every render.

Example: @api set course(value) { this._course = value; this.total = value.fee * value.seats; } get course() { return this._course; }

LWC Communication Interview Questions on Child to Parent

Q16: How does a child notify a parent?

By dispatching a custom event.

Example: this.dispatchEvent(new CustomEvent(‘selected’, { detail: { courseId: this.courseId } }));

Follow-up you may get: Can you use the standard Event class? Yes, but CustomEvent is needed to send detail.

Q17: What are the naming rules for an event?

Lowercase, no hyphens, no spaces, and no on prefix in the event name itself.

Name it like selected or levelchange. The parent adds on in the markup: onselected={handleSelected}.

Interview tip: give a bad and a good event name. It shows you know the rule.

Q18: Why no hyphens?

Because the markup handler name would become unclear, and camelCase does not work in HTML attributes either.

A name like level-change would need an attribute onlevel-change, which LWC does not support.

Q19: Where does the data go?

In the detail property of the event.

Example: new CustomEvent(‘saved’, { detail: { id: newId, name: courseName } }); and the parent reads event.detail.id.

Interview tip: mention detail before anyone asks. It is the expected answer.

Q20: Should detail hold a record or an id?

Prefer IDs and simple values, because detail is passed by reference and the receiver could change a shared object.

If you must send an object, send a copy. Small, plain data keeps components independent.

Q21: How does a parent listen in markup?

With on plus the event name as an attribute on the child tag.

Example: <c-course-list onselected={handleSelected}></c-course-list>

Q22: How does a parent listen in JavaScript?

With addEventListener on the element, usually when the child was created dynamically.

Example: this.refs.list.addEventListener(‘selected’, this.handleSelected.bind(this)); in renderedCallback, with a guard so it is added once.

Follow-up you may get: Do you need to remove the listener? Yes, if the element can outlive the component.

Q23: Why does event.target show the host element in the parent?

Events crossing a shadow boundary are retargeted, so the target looks like the host element.

This hides the child’s internal structure from the parent, which keeps components independent.

Interview tip: “read from detail, not target” is the practical lesson interviewers want.

Q24: What does that mean for your code?

Read the data from event.detail, not from event.target.

event.target only tells you which child fired the event, not its internal elements or values.

Q25: What do bubbles and composed do?

bubbles lets the event travel up through parents, and composed lets it cross shadow boundaries.

bubblescomposedWho can hear it
falsefalseOnly the component that fired it, and listeners on its host in the direct parent
truefalseParents inside the same shadow tree
truetrueEvery ancestor up to the document
falsetrueHosts of each shadow boundary it crosses, rarely used

Both false, so only the direct parent hears the event.

That keeps the event part of a clear contract between one parent and one child.

Interview tip: say you keep both false by default and explain why.

Q27: When would you set both true?

Rarely. Use them when an event must reach a component several levels up that you do not control, like a container that listens for close or notification events.

Set them deliberately and document it, because any ancestor can then react.

Q28: What is the risk of a bubbling composed event?

Any ancestor can handle it, which makes the component harder to reason about and test.

Event names can also clash with other components’ events on the same page.

Q29: Can an event be cancelled?

Yes, with cancelable: true and preventDefault(), but it is uncommon in Salesforce components.

The child can check event.defaultPrevented after dispatching, for example to skip a default action the parent cancelled.

Follow-up you may get: Does LWC have event modifiers like stopPropagation? Yes, call event.stopPropagation() in the handler.

Q30: What is the difference between event.target and event.currentTarget?

target is the element where the event started, which may be a child inside the button. currentTarget is the element the handler is attached to. For data attributes on the clicked element, use currentTarget.

Q31: How does an LWC inside a flow screen send a value back to the flow?

Dispatch FlowAttributeChangeEvent from lightning/flowSupport with the output property name and value. The property must be @api and listed as an output in the component’s targetConfig.

Q32: How do you pass data from a loop item in a handler?

A data attribute on the element, read from the event target dataset.

Example: <button data-id={c.Id} onclick={handleClick}> and in the handler, event.currentTarget.dataset.id.

LWC Communication Interview Questions on Message Service

Q33: What is Lightning Message Service?

A publish and subscribe service that lets components anywhere on a Lightning page talk to each other.

They do not need to share a parent, and it works across LWC, Aura and Visualforce.

Interview tip: name the three things it connects: LWC, Aura and Visualforce.

Q34: What do you need to set up?

A message channel, defined as metadata, optionally with named fields.

Example: force-app/main/default/messageChannels/Course_Selected.messageChannel-meta.xml, deployed like other metadata.

Q35: How do you import the channel?

From @salesforce/messageChannel, using its API name.

Example: import COURSE_SELECTED from ‘@salesforce/messageChannel/Course_Selected__c’;

Follow-up you may get: Can a channel be used across namespaces? Only if it is exposed in the metadata.

Q36: Which functions publish and subscribe?

publish and subscribe, from lightning/messageService, plus unsubscribe to stop listening.

Example: publish(this.messageContext, COURSE_SELECTED, { courseId: id });

Q37: What does subscribe need besides the channel?

A message context and a handler function, and optionally a scope.

Example: this.sub = subscribe(this.messageContext, COURSE_SELECTED, (msg) => this.load(msg.courseId));

Q38: Where does the message context come from?

From a wired MessageContext property.

Example: @wire(MessageContext) messageContext; gives the component its context automatically.

Q39: Should you unsubscribe?

Yes, in disconnectedCallback, or the subscription outlives the component.

Example: disconnectedCallback() { unsubscribe(this.sub); this.sub = null; }

Interview tip: always mention unsubscribing. Forgetting it is a classic bug.

Q40: What happens if you skip that?

Handlers pile up, so one message triggers several responses.

A user who opens the same tab repeatedly can end up with the same handler running many times per message.

Q41: Can an Aura component use the same channel?

Yes. Aura uses lightning:messageChannel with the same channel, which is one of LMS’s main advantages.

That makes it ideal during migrations, when some components are Aura and others LWC.

Follow-up you may get: How does Aura publish? With component.find(‘channel’).publish(message).

Q42: Can a Visualforce page use it?

Yes, through the sforce.one message service JavaScript API in the page.

Visualforce pages in Lightning Experience can publish and subscribe on the same channels as components.

Q43: Does the message survive a page navigation?

No. Messages live only in memory for the current page.

If a value must survive navigation, save it in a record, a URL parameter or session storage.

Q44: Is the message service scoped to the page or the browser tab?

By default, a subscriber hears messages only while its area of the page is active. APPLICATION_SCOPE lets it hear messages from anywhere in the app.

Use APPLICATION_SCOPE for components like the utility bar that must react even when another tab is in front.

Follow-up you may get: Which import gives APPLICATION_SCOPE? lightning/messageService.

Q45: Why not use a global JavaScript variable instead?

Components are isolated by Lightning Web Security, so a shared global variable is not reliable or safe.

LMS is the supported way to share messages between components.

Q46: When should you use Lightning Message Service instead of events?

When the components do not share a parent, sit in different page regions, or one of them is Aura or Visualforce. For a direct parent and child, events are simpler and clearer.

Q47: How do you send a message to a utility bar component?

Publish on a message channel from the page component, and have the utility bar component subscribe with APPLICATION_SCOPE, so it hears messages even when it is not the active area.

Q48: Is pubsub still a valid pattern?

It was a community workaround before the message service, and new work should use the platform service.

Lightning Message Service covers the same need and works with Aura and Visualforce too.

Scenario Based LWC Communication Interview Questions

Q49: Scenario: a parent handler never fires. What do you check first?

The event name casing and the on prefix in the markup.

An event dispatched as courseSelected needs oncourseselected, which LWC does not allow, so use an all lowercase name like selected with onselected.

Q50: Scenario: an event reaches the grandparent but not the parent. How?

It bubbles and is composed, so another ancestor handled it, or the parent has no handler on the right element.

Check that the listener is on the child tag itself, and that no component in between calls stopPropagation().

Q51: Scenario: event.target.courseId is undefined in the parent. Why?

Retargeting. The parent sees the child’s host element, not its internals, so read the value from event.detail.

Put courseId in detail when you dispatch the event, and read event.detail.courseId in the parent.

Q52: Scenario: two sibling components must stay in sync. What do you build?

An event up to the shared parent, then a property down to the other child.

NeedPattern
Parent to child@api property or @api method
Child to parentCustom event with detail
Siblings with a shared parentEvent up, property down
Components with no shared parentLightning Message Service
Same record shown in many placesLightning Data Service cache

Interview tip: walk through the table from memory. It covers most communication questions.

Q53: Scenario: those siblings sit in different page regions. What changes?

There is no shared parent, so use Lightning Message Service.

One component publishes on a channel, and the other subscribes, even if they sit in different regions or tabs of the page.

Q54: Scenario: one message triggers four responses. What is wrong?

Missing unsubscribe calls, so old subscriptions are still active.

Unsubscribe in disconnectedCallback, and check you do not subscribe twice in connectedCallback.

Q55: Scenario: a message is published and nobody receives it. What do you check?

Whether the subscriber was on the page when the message was sent, because messages are not stored.

If the subscriber loads later, it misses the message. Have it read the current state on load, for example from a record or a URL parameter.

Interview tip: say messages are not stored. It explains many “nobody received it” bugs.

Q56: Scenario: a child must validate before the parent saves. What do you use?

A public @api method on the child that returns whether it is valid.

Example: if (!this.refs.addressForm.validate()) return; in the parent’s save handler.

Q57: Scenario: a child changes a value and the parent shows the old one. Why?

The child changed its own copy, so the parent was never told.

Fire an event with the new value, and let the parent update its field so the value flows back down.

Q58: Scenario: an LWC must talk to an Aura component. What is the answer?

Lightning Message Service, which both can use with the same channel.

For a direct parent and child, an Aura parent can also listen to an LWC child’s events with an on handler attribute.

Q59: Scenario: a developer proposes a global variable for shared state. What do you say?

Components are isolated, so use Lightning Message Service, or a record that LDS caches.

Globals break under Lightning Web Security and make behaviour hard to follow and test.

Q60: Scenario: a parent needs to refresh a child’s data after saving. What is the cleanest route?

Save through LDS, with the record API or a record form, so the child’s wire updates on its own.

If the save must go through Apex, call notifyRecordUpdateAvailable afterwards, or an @api refresh method on the child.

Q61: Scenario: a modal component must tell the page which option the user picked. How?

With LightningModal, call this.close(selectedOption), and the page gets the value from the promise returned by MyModal.open(). No event wiring is needed.

Q62: Scenario: a quick action LWC must close itself after saving. How?

Dispatch the CloseActionScreenEvent from lightning/actions after the save succeeds, so the quick action panel closes and the record page refreshes.

Q63: Scenario: an interviewer asks for the simplest rule to remember. What do you say?

Properties down, events up, message service across.

Properties down, events up, and Lightning Message Service across the page.

Common Mistakes Candidates Make

  • Giving one answer for both relationships, which LWC Communication Interview Questions are designed to catch
  • Naming an event with camel case or a hyphen
  • Reading event.target instead of event.detail in the parent
  • Setting bubbles and composed true out of habit
  • Forgetting to unsubscribe from a message channel
  • Letting a child mutate a public property

More LWC Communication Interview Questions

Q64: What does APPLICATION_SCOPE do in a Lightning Message Service subscription?

It lets a component receive messages from anywhere in the app, such as the utility bar or another console tab. Without it, a component only hears messages from the active area.

Q65: What are lightningMessageFields in a message channel?

Optional field descriptions in the channel metadata. They document what the message carries, which helps other developers.

Q66: What should an LMS message contain?

Small, plain data such as record ids and a few values. Let the receiver load anything larger itself.

Follow-up you may get: Is there a size limit? Keep messages small; large payloads slow every subscriber.

Q67: Can an event detail carry a function?

It should not. Keep detail to plain, serialisable data so the receiver cannot run code from another component by accident.

Q68: How does an LWC talk to a flow it sits in?

It dispatches events from lightning/flowSupport, such as FlowAttributeChangeEvent to update an output value or FlowNavigationNextEvent to move on.

Q69: How does an Aura parent listen to an LWC child event?

It sets a handler attribute named after the event, prefixed with on, on the child tag in its markup.

Q70: Does Lightning Message Service work across browser tabs?

No. It works within one browser tab. To share across tabs or users, use server data or platform events.

Q71: How do components stay in sync after a record is edited elsewhere?

Use the getRecord wire adapter, which updates from the Lightning Data Service cache, or call notifyRecordUpdateAvailable after an Apex update.

Each piece of data has one owner, so changes are easy to follow and components are easier to test and reuse.

Q73: How do you notify other users’ screens that data changed?

LMS works only in one browser tab. For other users, publish a platform event or use Change Data Capture, and have components subscribe with lightning/empApi to refresh when the event arrives.

Q74: Should components talk through Apex static variables?

No. Each Apex call is its own transaction, so static variables do not carry between calls. Share state on the client with properties, events and LMS, and on the server with records.

Q75: How do you test that a child fires the right event in Jest?

Create the child, add a listener with a mock function, trigger the action, then assert the mock was called with the expected detail.

Example: const handler = jest.fn(); element.addEventListener(‘selected’, handler); then click the button and expect(handler).toHaveBeenCalled(); and check handler.mock.calls[0][0].detail.

Best Practices to Mention in an Interview

  • Properties down, events up, message service across
  • Lowercase event names with the data in detail
  • Default to bubbles and composed false
  • Public methods for actions a parent must trigger
  • Unsubscribe in disconnectedCallback, every time
  • Prefer the record API for refreshes over a manual message
  • Keep the child’s public surface small and documented

Official Resources

Quick Recap

  • LWC Communication Interview Questions depend on where the components sit
  • Properties and public methods go down the tree
  • Custom events come back up, with data in detail
  • Retargeting means the parent sees the host, not the inner element
  • Lightning Message Service covers unrelated components and other frameworks
  • Always unsubscribe when the component is destroyed

What Is Next

Coming soon: LWC advanced interview questions on shadow DOM and security.