Nuxt/docs/3.api/1.components/6.nuxt-error-boundary.md

1.0 KiB

title description links
<NuxtErrorBoundary> The <NuxtErrorBoundary> component handles client-side errors happening in its default slot.
label icon to size
Source i-simple-icons-github https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/components/nuxt-error-boundary.ts xs

::tip The <NuxtErrorBoundary> uses Vue's onErrorCaptured hook under the hood. ::

Events

  • @error: Event emitted when the default slot of the component throws an error.

    <template>
      <NuxtErrorBoundary @error="logSomeError">
        <!-- ... -->
      </NuxtErrorBoundary>
    </template>
    

Slots

  • #error: Specify a fallback content to display in case of error.

      <template>
        <NuxtErrorBoundary>
          <!-- ... -->
          <template #error="{ error }">
            <p>An error occurred: {{ error }}</p>
          </template>
        </NuxtErrorBoundary>
      </template>
    

:read-more{to="/docs/getting-started/error-handling"}