Skip to main content
InterviewHubPRO
Section Overview
Q43

Question 43 of 50

Part 3: Advanced Internals, Performance & Production (Senior / Staff)

86%
Nuxt & Universal SSR (50 Qs)•Part 3: Advanced Internals, Performance & Production (Senior / Staff)

Nuxt 3 Error Handling Architecture: `createError`, `showError`, and `error.vue`.

senior LevelCode ExampleFormsPerformanceSystem Design

In Simple Words: Nuxt handles errors at multiple boundaries:

  1. API / Server errors: Throw using createError({ statusCode: 404, statusMessage: 'Post Not Found' }).
  2. Client errors: Handled via <NuxtErrorBoundary> component around subtrees.
  3. Fatal / Full-page errors: Catch-all page app/error.vue displays custom 404 or 500 error templates. Clear with clearError({ redirect: '/' }).
vue
<!-- error.vue: Root error page -->
<script setup lang="ts">
import type { NuxtError } from '#app';

const props = defineProps<{ error: NuxtError }>();
const handleError = () => clearError({ redirect: '/' });
</script>

<template>
  <div class="error-page">
    <h1>Error {{ error.statusCode }}</h1>
    <p>{{ error.message }}</p>
    <button @click="handleError">Back to Home</button>
  </div>
</template>