# What is refreshApex and how do you use it in an LWC?

**Topic:** Development · **Difficulty:** Medium · **Tags:** lwc, refreshapex, wire

Read it on the site: https://www.forcechallenges.com/interview-questions/what-is-refreshapex-and-how-do-you-use-it-in-an-lwc

## Answer

`refreshApex` (from `@salesforce/apex`) forces a wired Apex method to re-fetch data and update the cache, so the UI shows fresh results after a change.

You must keep a reference to the **entire wired response**, not just the data:
```javascript
import { refreshApex } from '@salesforce/apex';

@wire(getContacts, { accountId: '$recordId' })
wiredContacts(result) {
  this.wiredResult = result;
  if (result.data) this.contacts = result.data;
}

async handleSave() {
  await saveContact({ c: this.contact });
  await refreshApex(this.wiredResult);
}
```
For Lightning Data Service records use `notifyRecordUpdateAvailable` instead.

---
Source: ForceChallenges · last updated 2026-10-19
