Nuxt 3 reached end of life on 31 July 2026
It no longer receives bug fixes or security patches. Upgrade to Nuxt 4 or get extended support from HeroDevs
setResponseStatus
setResponseStatus sets the status (and optionally the statusText) of the response.
Nuxt provides composables and utilities for first-class server-side-rendering support.
setResponseStatus sets the status (and optionally the statusText) of the response.
setResponseStatus can only be called in the Nuxt context.const event = useRequestEvent()
// event will be undefined in the browser
if (event) {
// Set the status code to 404 for a custom 404 page
setResponseStatus(event, 404)
// Set the status message as well
setResponseStatus(event, 404, 'Page Not Found')
}
In the browser,
setResponseStatus will have no effect.