I have a an LWC component which is referred from aura wrapper. I need to trigger an action inside the LWC component on a button press from enclosing aura component. Requesting to provide input on the same.

| improve this question | | | | |

You can use api methods in LWC. These are exposed to parent components when decorated api. Here is an example:

Aura component:


<lightning:button label="Get From Poc" onclick="{!c.getFromPoc}" />
<c:poc aura:id="poc" />

and its JS:

getFromPoc : function (component, event, helper) {
    let myData = component.find("poc").getMyData();
    console.log("myData => ", myData);

Now the child LWC component poc:


import { LightningElement, wire, api } from 'lwc';

export default class Poc extends LightningElement {
    getMyData() {
        return 'some data from poc';

This method getMyData is exposed and can be invoked from parent component (Aura or LWC). Syntax will be same as aura:method invocation as you can see in aura component getFromPoc method.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.