---
title: "Response Handling"
description: "Response handling in Hono is managed through the `Context` object, which provides a unified API for generating HTTP responses. Whether you are returning plain text, JSON, or HTML, the `Context` ens..."
last_updated: "2026-07-02T09:15:05.407974+00:00"
canonical_url: "https://www.doc0.app/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/guide/core-concepts/response-handling"
---

Response handling in Hono is managed through the `Context` object, which provides a unified API for generating HTTP responses. Whether you are returning plain text, JSON, or HTML, the `Context` ensures your response is correctly formatted and allows you to easily attach headers or modify status codes.

## Basic Response Methods

Hono provides several helper methods on the `Context` object to send data back to the client. These methods automatically set the appropriate `Content-Type` header based on the data format.

| Method | Purpose | Typical Content-Type |
| :--- | :--- | :--- |
| `c.text()` | Sends plain text | `text/plain; charset=UTF-8` |
| `c.json()` | Sends JSON data | `application/json` |
| `c.html()` | Sends HTML content | `text/html; charset=UTF-8` |

#### Usage Examples

```ts
app.get('/api/user', (c) => {
  return c.json({ name: 'Hono' })
})

app.get('/greet', (c) => {
  return c.text('Hello, world!')
})
```

## Customizing Status and Headers

You can customize the response by chaining configuration methods before returning the final response, or by passing options directly to the helper methods.

1. **Using `.status()` and `.header()`:** Call these methods on the context to modify the state of the current request handler.
2. **Returning the response:** Use one of the helper methods (`.text()`, `.json()`, etc.) to finalize the response.

```ts
app.get('/custom', (c) => {
  c.status(201)
  c.header('X-Custom-Header', 'my-value')
  return c.text('Created!')
})
```

> [!TIP]
> You can also pass an optional status code or headers object directly into the response helper: `c.json({ success: true }, 202)`.

## Redirections

To redirect a user, use the `.redirect()` method. It takes a URL string and an optional HTTP status code (which defaults to `302 Found`).

```ts
app.get('/go-home', (c) => {
  return c.redirect('/')
})

app.get('/moved', (c) => {
  return c.redirect('/new-location', 301)
})
```

## Advanced Response Handling

### Streaming
For large responses or long-running tasks, use the `stream` helpers imported from the streaming module. This allows you to send data chunks to the client over time.

```ts
import { streamText } from 'hono/streaming'

app.get('/stream', (c) => {
  return streamText(c, async (stream) => {
    await stream.write('Hello ')
    await stream.writeln('World!')
  })
})
```

> [!IMPORTANT]
> Once you return a response from a handler, the context is marked as `finalized`. Attempting to modify headers or status codes after returning may lead to unexpected behavior if not handled via the `c.res` property.

## Related

- [Context API](https://www.doc0.app/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/guide/core-concepts/context-api)
- [Request Handling](https://www.doc0.app/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/guide/core-concepts/request-handling)


## Sitemap

See the full [sitemap](https://www.doc0.app/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/llms.txt) for all pages in this wiki.
