DocTreen

Quick start

Mount the docs UI on your existing app in under five minutes.

Pick your framework. Each example mounts the docs UI at /docs next to your existing router — no rewrite required.

const express = require('express');
const { expressAdapter } = require('doctreen/express');

const app = express();
app.use(express.json());

app.get('/users',  (req, res) => res.json([]));
app.post('/users', (req, res) => res.status(201).json({ id: 1 }));

// Mount after your routes
app.use(expressAdapter(app, {
  meta: { title: 'My API', version: '1.0.0' },
}));

app.listen(3000, () => console.log('Docs at http://localhost:3000/docs'));
const fastify = require('fastify')();
const { fastifyAdapter } = require('doctreen/fastify');

// Call BEFORE registering routes — uses the onRoute hook
fastifyAdapter(fastify, {
  meta: { title: 'My API', version: '1.0.0' },
});

fastify.get('/users', async (req, reply) => reply.send([]));

fastify.listen({ port: 3000 });
// Hono v4 is ESM-only — run with: npx tsx hono-app.js
import { Hono } from 'hono';
import { serve } from '@hono/node-server';
import { honoAdapter } from 'doctreen/hono';

const app = new Hono();

app.get('/users', (c) => c.json([]));

// Can be called before or after routes
honoAdapter(app, { meta: { title: 'My API', version: '1.0.0' } });

serve({ fetch: app.fetch, port: 3000 });
const Koa    = require('koa');
const Router = require('@koa/router');
const { koaAdapter } = require('doctreen/koa');

const app    = new Koa();
const router = new Router();

router.get('/users', (ctx) => { ctx.body = []; });

// Can be called before or after routes
koaAdapter(router, { meta: { title: 'My API', version: '1.0.0' } });

app.use(router.routes());
app.use(router.allowedMethods());
app.listen(3000);
import 'reflect-metadata';
import { NestFactory } from '@nestjs/core';
import { nestAdapter } from 'doctreen/nest';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  // Call after NestFactory.create(), before app.listen()
  nestAdapter(app, {
    meta: { title: 'My API', version: '1.0.0' },
  });

  await app.listen(3000);
  console.log('Docs at http://localhost:3000/docs');
}
bootstrap();

Then annotate your controller methods with @DocRoute — see NestJS adapter.

Visit the configured docsPath (default: /docs) to see your documentation.

Next steps

On this page