RefreshviewApi in LWC

 In Lightning web components, in most cases, we might have used the refreshApex feature to refresh the component data. But in some scenarios, we might want to refresh the standard Salesforce components, such as recordDetail and relatedList.

         Using new Lightning RefreshView API, you will be able to refresh your Standard Components View from your Custom Lightning Web Component.

The RefreshView API and lightning/refresh module provide a standard way to refresh component data in LWC and Aura.

  • Create a lightning web component and import the refresh API feature.
import { RefreshEvent } from 'lightning/refresh';

  • In this example, we are using the record form to create a new record. After creating a record, the standard related list component would reflect the changes.


         <lightning-record-edit-form object-api-name="Contact"   
               <lightning-input-field  field-name="FirstName">
               <lightning-input-field field-name="LastName">
               <lightning-input-field field-name="AccountId">
               <lightning-input-field field-name="Email">
               <div style="margin-left:35%;width:fit-content">
                           <lightning-button label="Cancel" type="reset"           
                           <lightning-button label="save" type="submit"   


import { LightningElement } from ‘lwc’;

import { RefreshEvent } from ‘lightning/refresh’;

import {ShowToastEvent} from ‘lightning/platformShowToastEvent’;

export default class RefreshViewApi extends LightningElement {



                    new ShowToastEvent({


                                message:’Record Created Successfully!’,




                this.dispatchEvent(new RefreshEvent());




Before creating the record,

After creating the record,

The refreshView API will refresh the component. so that we don’t need to refresh the page manually.