From 2dd78e798a2f386d5a70becc55064f344e0aa8bc Mon Sep 17 00:00:00 2001 From: Shannon Anahata Date: Tue, 9 Sep 2025 10:42:13 -0700 Subject: [PATCH] hono runtime updates --- .../guides/cloudflare/frameworks/hono.mdx | 28 +++++++ .../javascript/guides/hono/index.mdx | 82 ++++++++++++++++++- 2 files changed, 106 insertions(+), 4 deletions(-) diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx index 2e2b53b152c72..aa9694271b226 100644 --- a/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx +++ b/docs/platforms/javascript/guides/cloudflare/frameworks/hono.mdx @@ -5,6 +5,13 @@ description: "Learn how to instrument your Hono app on Cloudflare Workers and ca + + The community-maintained `@hono/sentry` middleware that uses `toucan-js` has been deprecated in favor of + using `@sentry/cloudflare` directly. + If you're currently using the `@hono/sentry` middleware with `toucan-js`, you should migrate to + `@sentry/cloudflare` directly as shown in this guide. + + ## Step 1: Install Choose the features you want to configure, and this guide will show you how: @@ -36,6 +43,27 @@ The main Sentry configuration should happen as early as possible in your app's l platform="javascript.cloudflare.workers" /> +### Migration from Community Middleware + +If you're currently using the `@hono/sentry` middleware, migrate to the official `@sentry/cloudflare` middleware: + +```javascript +// New approach using official Sentry SDK +import { Hono } from 'hono'; +import * as Sentry from '@sentry/cloudflare'; + +const app = new Hono(); + +// Wrap your app with Sentry +export default Sentry.withSentry( + (env: Env) => ({ + dsn: '___PUBLIC_DSN___', + tracesSampleRate: 1.0, + }), + app +); +``` + - - This guide assumes you're using the **Node.js runtime** for Hono. For setup - instructions on Cloudflare Workers, see our [Hono on Cloudflare - guide](/platforms/javascript/guides/cloudflare/frameworks/hono/). + + This guide focuses on the **Node.js runtime** for Hono. For other runtimes, see the links below. + If you are using the `@sentry/cloudflare` middleware, see the [Hono on Cloudflare guide](/platforms/javascript/guides/cloudflare/frameworks/hono/). +## Runtime Support + +Hono works across multiple JavaScript runtimes. Choose the appropriate Sentry SDK for your environment: + +- **Node.js**: Use `@sentry/node` (this guide) +- **Cloudflare Workers**: Use `@sentry/cloudflare` - see our [Hono on Cloudflare guide](/platforms/javascript/guides/cloudflare/frameworks/hono/) +- **Deno**: Use `@sentry/deno` - see our [Deno guide](/platforms/javascript/guides/deno/) (Beta) +- **Bun**: Use `@sentry/bun` - see our [Bun guide](/platforms/javascript/guides/bun/) + + + The community middleware `@hono/sentry` has been deprecated in favor of using Sentry's official + packages, which provide better performance and more features. If you're currently using `@hono/sentry` middleware, you'll need to migrate to `@sentry/cloudflare`. + + +## Runtime-Specific Setup + +### Node.js Runtime (This Guide) + +This guide focuses on Node.js. The setup uses `@sentry/node` and follows standard Node.js patterns. + + +### Other Runtimes + +For other runtimes, use the appropriate Sentry SDK: + + +```javascript +// For Deno, use @sentry/deno (currently in Beta) +import * as Sentry from "npm:@sentry/deno"; +import { Hono } from "hono"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, +}); + +const app = new Hono(); +// Your Hono app setup... +``` + + + +```javascript +// For Bun, use @sentry/bun +import * as Sentry from "@sentry/bun"; +import { Hono } from "hono"; + +// Initialize Sentry before importing other modules +Sentry.init({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, +}); + +const app = new Hono(); +// Your Hono app setup... +``` + + + +```javascript +// For Cloudflare Workers, use @sentry/cloudflare +import * as Sentry from "@sentry/cloudflare"; +import { Hono } from "hono"; + +const app = new Hono(); + +export default Sentry.withSentry( + (env: Env) => ({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + }), + app +); +``` +