> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/nuxt/nuxt/llms.txt
> Use this file to discover all available pages before exploring further.

# useError

> useError composable returns the global Nuxt error that is being handled.

## 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.

```ts theme={null}
const error = useError()
```

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

## Parameters

This composable does not take any parameters.

## Return Values

<ResponseField name="error" type="Ref<NuxtError | undefined>">
  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.

  <ResponseField name="status" type="number">
    HTTP status code of the error.
  </ResponseField>

  <ResponseField name="statusText" type="string">
    HTTP status text of the error.
  </ResponseField>

  <ResponseField name="message" type="string">
    Error message.
  </ResponseField>

  <ResponseField name="data" type="T">
    Optional additional error data.
  </ResponseField>

  <ResponseField name="error" type="true">
    Flag indicating this is an error object.
  </ResponseField>
</ResponseField>

## Example

```vue theme={null}
<script setup lang="ts">
const error = useError()

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

## Type

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

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