Skip to content

Return Types

Handlers in Xink can return several different types of values. These are automatically normalized into proper HTTP responses.

  • JSX → rendered to HTML (text/html)
  • string / number → returned as text/plain
  • object → returned as application/json
  • Response → passed through as‑is
  • null / undefined204 No Content

Returns an HTML response.

export const GET = (() => {
return <h1>Hello from JSX!</h1>
})

Returns a text/plain response. Numbers are converted to strings.

export const GET = () => 'Ok'
export const GET = () => 42

Returns an application/json response.

export const GET = () => {
return {
"message": "Welcome to xink!"
}
}

You can also return a raw Response if you need full control.

export const GET = (() => {
return new Response("Custom", { status: 202 })
})

Returning null or undefined results in a 204 No Content response.

export const GET = (() => null)