Documentación offline Nuxt main

useResponseHeader

main Documentación oficial Licencia MITDescargado el 2026-08-02

En esta página

::important This composable is available in Nuxt v3.14+. ::

You can use the built-in useResponseHeader composable to set any server response header within your pages, components, and plugins.

// Set a custom response header
const header = useResponseHeader('X-My-Header')
header.value = 'my-value'

Example#

We can use useResponseHeader to easily set a response header on a per-page basis.

```vue [app/pages/test.vue]

We can use `useResponseHeader` for example in Nuxt [middleware](/docs/4.x/directory-structure/app/middleware) to set a response header for all pages.

```ts [app/middleware/my-header-middleware.ts]
export default defineNuxtRouteMiddleware((to, from) => {
  const header = useResponseHeader('X-My-Always-Header')
  header.value = `I'm Always here!`
})