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 / undefined →
204 No Content
Returns an HTML response.
export const GET = (() => { return <h1>Hello from JSX!</h1>})
Text and Numbers
Section titled “Text and Numbers”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!" }}
Response
Section titled “Response”You can also return a raw Response
if you need full control.
export const GET = (() => { return new Response("Custom", { status: 202 })})
No Content
Section titled “No Content”Returning null
or undefined
results in a 204 No Content
response.
export const GET = (() => null)