Documentation Index
Fetch the complete documentation index at: https://docs.subtrace.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Here’s a quick guide to setting up Subtrace in your Cloudflare Workers.
First, add @subtrace/cloudflare to your Worker package.json:
npm install @subtrace/cloudflare
Wrap your Worker’s fetch handler to use the Subtrace middleware:
import { subtrace } from "@subtrace/cloudflare";
export default {
fetch: subtrace(async (request, env, ctx) => {
return new Response("Hello World!");
}),
};
Set a SUBTRACE_TOKEN environment variable in your Wrangler config file:
{
"name": "my-worker",
"main": "src/index.js",
"compatibility_date": "2025-09-27",
"vars": {
// Go to https://subtrace.dev/dashboard to generate a token
"SUBTRACE_TOKEN": "subt_..."
}
}
Deploy your Cloudflare Worker:
And that’s it, you can now see all inbound and outbound HTTP requests in your Cloudflare Worker via the Subtrace dashboard!