---
title: "Hono"
description: "Learn how to set up Sentry in your Hono app on Node.js, Bun, Deno, or Cloudflare Workers."
url: https://docs.sentry.io/platforms/javascript/guides/hono/
---

# Sentry for Hono

##### Using @sentry/hono?

Starting with version `11.2.0`, the Sentry SDK for your runtime instruments Hono, so you don't need `@sentry/hono` anymore. **Update to `11.2.0` or above** and [migrate to the SDK for your runtime](https://docs.sentry.io/platforms/javascript/guides/hono.md#migrate-from-sentryhono).

[Hono](https://hono.dev/) doesn't need its own Sentry SDK. Set up Sentry for the runtime your app runs on, and `honoIntegration` instruments Hono automatically:

* Names each request after its route, for example `GET /users/:id`
* Captures errors from your routes and middleware
* Creates spans for incoming requests and each middleware when tracing is enabled

This needs Sentry JavaScript SDK version `11.2.0` or above, and Hono `4.4.9` or above.

## [Set Up Sentry for Your Runtime](https://docs.sentry.io/platforms/javascript/guides/hono.md#set-up-sentry-for-your-runtime)

* [![javascript.node icon](https://docs.sentry.io/_next/static/media/nodejs.79546009.svg)Node.js](https://docs.sentry.io/platforms/javascript/guides/node.md?framework=hono)
* [![javascript.bun icon](https://docs.sentry.io/_next/static/media/bun.64e0abda.svg)Bun](https://docs.sentry.io/platforms/javascript/guides/bun.md?framework=hono)
* [![javascript.deno icon](https://docs.sentry.io/_next/static/media/deno.0ad064af.svg)Deno](https://docs.sentry.io/platforms/javascript/guides/deno.md?framework=hono)
* [![javascript.cloudflare icon](https://docs.sentry.io/_next/static/media/cloudflare.7e288bf9.svg)Cloudflare Workers](https://docs.sentry.io/platforms/javascript/guides/cloudflare.md?framework=hono)

## [Customize Error Capturing](https://docs.sentry.io/platforms/javascript/guides/hono.md#customize-error-capturing)

By default, the SDK skips errors with a 3xx or 4xx status code, since they're usually expected redirects or client errors. To change this, pass a `shouldHandleError` callback to `honoIntegration()`. It receives the thrown error. Return `true` to capture it or `false` to skip it:

```javascript
import * as Sentry from "@sentry/node";

Sentry.init({
  dsn: "https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
  integrations: [
    Sentry.honoIntegration({
      shouldHandleError(error) {
        const status = error?.status;
        // Capture 401/403 in addition to the default 5xx errors
        return (
          status === 401 ||
          status === 403 ||
          typeof status !== "number" ||
          status >= 500
        );
      },
    }),
  ],
});
```

*Other available variations of the above snippet: Bun, Deno, Cloudflare Workers*

## [Instrument Hono Manually](https://docs.sentry.io/platforms/javascript/guides/hono.md#instrument-hono-manually)

The SDK instruments Hono's code when Hono loads, so Sentry must load before your app. The runtime guides set this up for you. If your setup can't do this, for example a Cloudflare Worker that you deploy with Wrangler and without the Vite plugin, add `honoMiddleware()` as the first middleware of your app:

```typescript
import { Hono } from "hono";
import * as Sentry from "@sentry/cloudflare";

const app = new Hono();

app.use(Sentry.honoMiddleware(app));

// Your routes here

export default Sentry.withSentry(
  (env) => ({
    dsn: "https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
    tracesSampleRate: 1.0,
  }),
  app,
);
```

`honoMiddleware()` accepts the same `shouldHandleError` option as `honoIntegration()`. You can keep it when you add the Vite plugin later, because the SDK handles each request only once.

## [Migrate From `@sentry/hono`](https://docs.sentry.io/platforms/javascript/guides/hono.md#migrate-from-sentryhono)

If your app uses the `@sentry/hono` package or the `@hono/sentry` community middleware, move to the SDK for your runtime:

1. Remove `@sentry/hono` (or `@hono/sentry` and `toucan-js`) from your dependencies.
2. Remove the `sentry()` middleware from your app.
3. Set up Sentry with the guide for your runtime.
4. Move your `sentry()` options to `Sentry.init()`, or to `instrument.server.ts` on Cloudflare Workers.
5. Move `shouldHandleError` to `honoIntegration()`.

---

Find other pages: [Sitemap](https://docs.sentry.io/sitemap.md) lists every page with a one-line summary, and [llms.txt](https://docs.sentry.io/llms.txt) gives an overview with guidance for agents.
