clearError()

Clears the active Nuxt error and optionally redirects.

Since Nuxt 3.0 Spec ↗

Syntax

await clearError(options?)

Parameters

NameTypeRequiredDescription
options { redirect?: string } No Optional `redirect` path to navigate to after clearing the error.

Returns

Promise<void> — Resolves once the error is cleared.

Examples

<script setup lang="ts">
// Inside error.vue — "Back to home" button
const handleError = () => clearError({ redirect: '/' })
</script>

<template>
  <button @click="handleError">Go home</button>
</template>
<script setup lang="ts">
const error = useError()
function retry() {
  clearError()
}
</script>

Notes

Typically used in the global `error.vue` page to dismiss the error and continue. Without `redirect` it clears the error and stays; passing `redirect` clears then navigates there. Resets `useError()` to `null`.

See also