Skip to content

How to return 204 status code in route.js? #51475

Closed Answered by icyJoseph
kmvan asked this question in App Router
Discussion options

You must be logged in to vote

Just use the new Response form:

For example for a 200,

export async function GET(request: Request) {
  return new Response('Hello, Next.js!', {
    status: 200,
  })
}

Or a 204:

export async function GET(request: Request) {
  return new Response(null, {
    status: 204,
  })
}

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
1 reply
@kmvan
Comment options

Comment options

You must be logged in to vote
6 replies
@donprasetiyo
Comment options

@kmvan
Comment options

@homocodian
Comment options

@hakan-berat
Comment options

@homocodian
Comment options

Answer selected by kmvan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants