Installing Required Packages
To begin, install the necessary packages in your Hono project:Obtain the Development Server API Key
To locate your development Server API key, login to the Trigger.dev dashboard and select the Project you want to connect to. Then click on the Environments & API Keys tab in the left menu. You can copy your development Server API Key from the field at the top of this page. (Your development key will start withtr_dev_).
Configure Environment Variables
Add the following environment variables to your.env file (or .dev.vars file if you are using Cloudflare Workers):
<development server api key> with the actual API key obtained from the previous step.
Enable Node.js compatibility
If you are using Cloudflare Workers, you’ll need to enable Node.js compatibility mode in yourwrangler.toml file:
Add Middelware to Your Hono app
Our@trigger.dev/hono package provides two different ways of configuring the necessary middleware needed to connect your Hono app to Trigger.dev. addMiddleware which should be used for Cloudflare Workers, and createMiddleware which can be used with Bun, Deno, and Node.js.
Cloudflare Workers
Because environment variables in Cloudflare Workers aren’t available in the global scope, but are instead available only inside the fetch handler, we need to use theaddMiddleware function to add the necessary middleware to your Hono app.
addMiddleware is a function that receives the environment variables (either from .dev.vars in development or from Cloudflare when deployed), and returns a TriggerClient instance. This function will be called once per request.
If you want, you can extract our the function that creates the TriggerClient instance into a separate file, and import it into your index.ts file:
TriggerClient and setup the middleware, you can add your first job:
jobs.ts, we define our first job using the new Job constructor from @trigger.dev/sdk, and then in trigger-client.ts we attach the job to the TriggerClient instance.
Bun
If you are using Bun, you can use thecreateMiddleware function to create the necessary middleware to connect your Hono app to Trigger.dev and define your TriggerClient and jobs in the global scope:
Deno
Import trigger.dev packages with Deno using npm: specifiers:index.ts
.env file on startup, pass the deno run command a --env flag:
dotenv package:
index.ts
--allow-env and --allow-read flags:
TriggerClient, define our jobs, and create the middleware:
index.ts
Node.js
Node.js works very similarly to Deno and Bun, in that you can define theTriggerClient and jobs in the global scope, and then create the middleware and add it to your Hono app:
index.ts

