How to Refresh Page using Lightning Web Component

Lightning Web Components

Hi Trailblazer,

I came across a scenario where I need to refresh the whole page after we perform the logic from an inline LWC. After hitting hard I found below solutions.

  • Use Web Component inside Aura Component and then dispatch the event from the LWC which will be handled by parent AURA Component and then from Aura Component refresh the page.
  • Use eval JavaScript function to refresh the page from the LWC itself. Below is the code for the same, copy and paste the code after the line from where you wanted to refresh the page.
eval("$A.get('e.force:refreshView').fire();");

Leave a Reply