Files
gil-wiki/reference/4.api/2.composables/use-error.md
gil 5f664546cf feat: 위키 저장소 초기 커밋
- CLAUDE.md 운영 규칙
- wiki/ 정리된 지식 페이지 (Nuxt + Claude Code)
- raw/ 원본 자료
- reference/ Nuxt 4.x 공식 문서

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 00:31:51 +09:00

1.3 KiB

title, description, links
title description links
useError useError composable returns the global Nuxt error that is being handled.
label icon to size
Source i-simple-icons-github https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/error.ts xs

Usage

The useError composable returns the global Nuxt error that is being handled and is available on both client and server. It provides a reactive, SSR-friendly error state across your app.

const error = useError()

You can use this composable in your components, pages, or plugins to access or react to the current Nuxt error.

Type

interface NuxtError<DataT = unknown> {
  status: number
  statusText: string
  message: string
  data?: DataT
  error?: true
}

export const useError: () => Ref<NuxtError | undefined>

Parameters

This composable does not take any parameters.

Return Values

Returns a Ref containing the current Nuxt error (or undefined if there is no error). The error object is reactive and will update automatically when the error state changes.

Example

<script setup lang="ts">
const error = useError()

if (error.value) {
  console.error('Nuxt error:', error.value)
}
</script>

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