clearNuxtData()

Clears cached data, error, and status for given useAsyncData keys.

Since Nuxt 3.5 Spec ↗

Syntax

clearNuxtData(keys?)

Parameters

NameTypeRequiredDescription
keys string | string[] | ((key: string) => boolean) No Key, array of keys, or a predicate. When omitted, all cached async data is cleared.

Returns

void — Resets data to its default and status to idle.

Examples

<script setup lang="ts">
function logout() {
  clearNuxtData('user')
  navigateTo('/login')
}
</script>
<script setup lang="ts">
// Clear everything that starts with "cart-"
clearNuxtData((key) => key.startsWith('cart-'))
</script>

Notes

Unlike `refreshNuxtData`, this does not re-fetch; it invalidates the cached payload so the next mount (or manual `refresh()`) fetches fresh. Useful on logout or when invalidating stale user-scoped data.

See also