To get started, first install the @sentry/hono package:
npm install @sentry/honoEither set the nodejs_compat compatibility flags in your wrangler.jsonc/wrangler.toml config. This is because the SDK needs access to the AsyncLocalStorage API to work correctly.
compatibility_flags = ["nodejs_compat"]Initialize the Sentry Hono middleware as early as possible in your app:
import { sentry } from '@sentry/hono/cloudflare';
const app = new Hono();
app.use(
'*',
sentry(app, {
dsn: 'your-sentry-dsn',
}),
);
export default app;
{ "compatibility_flags": ["nodejs_compat"], }