Skip to main content

What is BE Monorepo?

BE Monorepo is a batteries-included backend template built on Hono 4, a fast and lightweight web framework. It provides a complete foundation for building production-ready APIs with TypeScript, featuring authentication, database management, and observability out of the box. The template is organized as a monorepo using Bun workspaces, allowing you to share code between multiple applications and packages while maintaining clear boundaries and type safety.

Why use BE Monorepo?

Skip weeks of setup and configuration. BE Monorepo includes production-tested patterns for authentication, database migrations, error handling, and API documentation.
Written entirely in TypeScript with strict configuration. Drizzle ORM provides type-safe database queries, while Zod ensures runtime validation matches your types.
OpenTelemetry integration provides traces, metrics, logs, and profiling. Connect to Grafana dashboards to monitor your application in development and production.
Built with modern tools like Bun for fast package management, Biome for linting and formatting, and Changesets for version management.

Key features

Hono 4 framework

Ultra-fast web framework with middleware for CORS, CSRF, rate limiting, and more. Built-in OpenAPI documentation generation.

Better Auth

Modern authentication library with session management, user roles, and built-in security features.

Drizzle ORM

Type-safe PostgreSQL database access with migrations, schema generation, and a built-in studio UI.

OpenTelemetry

Full observability stack with automatic instrumentation for traces, metrics, and logs.

Monorepo structure

Organized workspace with apps and shared packages. Easily add new services while sharing common code.

Developer experience

Hot reload with Bun, unified linting with Ultracite, type checking, and pre-commit hooks with Husky.

What’s included

The monorepo comes with a fully configured Hono application and shared packages:

Applications

  • @workspace/hono - Main Hono 4 API server with authentication, database, and observability

Packages

  • @workspace/core - Shared utilities, constants, types, and HTTP services
  • @workspace/typescript-config - Shared TypeScript configuration for consistent compiler settings

Infrastructure

  • Docker Compose configuration for PostgreSQL, Redis, and Grafana observability stack
  • GitHub Actions CI/CD workflows for testing and deployment
  • Environment variable management with dotenvx

Technology stack

{
  "name": "be-monorepo",
  "packageManager": "[email protected]",
  "engines": {
    "node": ">=24.14.0"
  },
  "workspaces": [
    "apps/*",
    "packages/*"
  ]
}
Runtime flexibility: The template supports both Bun and Node.js runtimes. Use bun hono dev for Bun or bun hono node:dev for Node.js.

Core middleware

The Hono application comes pre-configured with essential middleware from apps/hono/src/app.ts:
apps/hono/src/app.ts
import { OpenAPIHono } from "@hono/zod-openapi";
import { httpInstrumentationMiddleware } from "@hono/otel";

const app = new OpenAPIHono();

app.use("*",
  httpInstrumentationMiddleware({ serviceName: "hono-api" }),
  contextStorage(),
  loggerMiddleware(),
  cors({ origin: [ENV.APP_URL] }),
  requestId(),
  timing(),
  csrf({ origin: [ENV.APP_URL] }),
  secureHeaders(),
  prettyJSON()
);
This setup provides request tracing, logging, CORS protection, CSRF protection, security headers, and automatic JSON formatting.

Next steps

Ready to get started? Follow the quickstart guide to clone the repository, install dependencies, and run your first API server.

Quickstart guide

Get your backend running in under 5 minutes

Build docs developers (and LLMs) love