Skip to content

Latest commit

 

History

History
67 lines (46 loc) · 2.13 KB

File metadata and controls

67 lines (46 loc) · 2.13 KB

Sentry

Official Sentry SDK for Hono (ALPHA)

npm version npm dm npm dt

This SDK is compatible with Hono 4+ and is currently in ALPHA. Alpha features are still in progress, may have bugs and might include breaking changes. Please reach out on GitHub if you have any feedback or concerns.

Links

The current Hono SDK Docs explain using Sentry in Hono by using other Sentry SDKs (e.g. @sentry/node or @sentry/cloudflare)

Install

To get started, first install the @sentry/hono package:

npm install @sentry/hono

Setup (Cloudflare Workers)

1. Enable Node.js compatibility

Set the nodejs_compat compatibility flag 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"],
}
compatibility_flags = ["nodejs_compat"]

2. Initialize Sentry in your Hono app

Initialize the Sentry Hono middleware as early as possible in your app:

import { sentry } from '@sentry/hono/cloudflare';

const app = new Hono();

// Initialize Sentry middleware right after creating the app
app.use(
  '*',
  sentry(app, {
    dsn: 'your-sentry-dsn',
    // ...other Sentry options
  }),
);

// ... your routes and other middleware

export default app;