Skip to content

Treblle with AdonisJS

Legacy Notice: The dedicated AdonisJS integration is in maintenance mode. We recommend using our unified JavaScript SDK (treblle-node) instead, which provides better support and more frequent updates. Support for this integration will end on December 31, 2025. To migrate, follow the updated setup guide below.

We now recommend using our unified JavaScript SDK which works with AdonisJS:

Terminal window
npm install treblle@^2.0.0

Initialize in your AdonisJS application using Koa support (since Adonis runs on Koa):

start/kernel.ts
import { koaTreblle } from "treblle";
Server.middleware.register([
() => ({
handle: koaTreblle({
sdkToken: process.env.TREBLLE_SDK_TOKEN,
apiKey: process.env.TREBLLE_API_KEY,
}),
}),
]);

The original AdonisJS-specific integration is still available but no longer actively maintained.

If you’re still using the legacy integration:

Terminal window
npm i @treblle/adonisjs --save

After installation, run the configuration command:

Terminal window
node ace configure @treblle/adonisjs

This will create the treblle-adonisjs config in config/treblle.ts.

treblle-adonisjs requires the following environment variables:

  • TREBLLE_API_KEY
  • TREBLLE_PROJECT_ID

Validate them in your env.ts file:

TREBLLE_API_KEY: Env.schema.string(),
TREBLLE_PROJECT_ID: Env.schema.string(),

Add the middleware globally in your start/kernel.ts:

Server.middleware.register([() => import('@treblle/adonisjs')])

Or use it as a named middleware for specific routes:

start/kernel.ts
Server.middleware.registerNamed({
treblle: () => import('@treblle/adonisjs'),
})

Then apply to routes:

Route.group(() => {
Route.post('/posts', async ({ request }) => {
return {
success: true,
message: 'Post created successfully',
data: request.body(),
}
})
})
.prefix('/api/v1')
.middleware('treblle')

To migrate from the legacy integration to the unified SDK:

  1. Install the new package:

    Terminal window
    npm install treblle@^2.0.0
    npm uninstall @treblle/adonisjs
  2. Update your environment variables from TREBLLE_API_KEY / TREBLLE_PROJECT_ID to TREBLLE_SDK_TOKEN / TREBLLE_API_KEY

  3. Update your middleware registration in start/kernel.ts to use the Koa middleware from the unified SDK

  4. Test your API endpoints to ensure requests are being captured

For questions during migration, contact support at support@treblle.com