Trasys
Node.js SDKFrameworks

Hono

Apply the Trasys SDK's middleware to every route in a Hono application with app.use('*', sdk.honoMiddleware()) to automatically capture request spans.

Hono

// index.js
require('dotenv').config();
const { sdk } = require('./trasys'); // SDK must be required first

const { Hono } = require('hono');
const app = new Hono();

// Apply to all routes using '*'
app.use('*', sdk.honoMiddleware());

app.get('/users/:id', async (c) => {
  const user = await db.findUser(c.req.param('id'));
  return c.json(user);
});

export default app;

TypeScript

// index.ts
import 'dotenv/config';
import { sdk } from './trasys';

import { Hono } from 'hono';

const app = new Hono();

app.use('*', sdk.honoMiddleware());

app.get('/users/:id', async (c) => {
  const user = await db.findUser(c.req.param('id'));
  return c.json(user);
});

export default app;

Scoped middleware

Apply the middleware only to specific route groups by using a path prefix instead of '*':

// Apply only to /api/* routes
app.use('/api/*', sdk.honoMiddleware());

Bun + Hono

Hono is commonly used with Bun. The middleware works normally on Bun, but outbound HTTP spans are not available due to a platform limitation.

// Bun entry point
import 'dotenv/config';
import { sdk } from './trasys';
import { Hono } from 'hono';

const app = new Hono();
app.use('*', sdk.honoMiddleware());

// Routes here...

export default {
  port: 3000,
  fetch: app.fetch,
};

Next steps

On this page