Skip to content

A TypeScript starter template for building Cloudflare Workers using Hono with Drizzle ORM and Zod validation.

License

Notifications You must be signed in to change notification settings

Musanna-al-akil/cloudflare-hono-drizzle-zod-starter-pack

Repository files navigation

Cloudflare Hono Drizzle Zod Starter Kit

A TypeScript starter template for building Cloudflare Workers using Hono framework with Drizzle ORM and Zod validation.

Features

  • 🔥 Hono - Fast, Lightweight, Web-standards web framework
  • 🔧 Drizzle ORM - TypeScript ORM for SQL databases
  • Zod - TypeScript-first schema validation
  • 👷 Cloudflare Workers - Serverless platform
  • Vitest for testing
  • 📘 TypeScript support
  • 🎨 ESLint + Prettier for code formatting @antfu/eslint-config
  • 🔄 Husky + lint-staged for git hooks

Project Structure

├── .github/        # GitHub-specific configurations 
│   └── workflows/  # Automation workflows for testing, deployment, etc.
├── .husky/         # Git hooks (e.g., pre-commit)
├── .vscode/        # VS Code workspace-specific settings
├── src/ 
│ ├── config/       # Configuration files
│ ├── db/           # Database related code
│ │ └── schema/     # Drizzle schema definitions
│ ├── middlewares/  # Hono middlewares
│ ├── routes/       # API routes
│ ├── services/     # Business logic
│ └── index.ts      # Entry point
├── tests/           # Test files
├── .env.example    # Environment variables
|── .dev.vars.example # Environment variables example
├── .lintstagedrc   # Configuration for lint-staged (pre-commit).
├── drizzle.config.ts # Drizzle configuration
|── eslint.config.mjs # eslint configuration
├── package.json   # Project metadata and dependencies.
├── tsconfig.json  # TypeScript configuration
└── wrangler.toml  # Cloudflare Workers configuration

Getting Started

  1. Clone the repository:

    git clone https://github.com/yourusername/cloudflare-hono-drizzle-zod-starter-pack
  2. Install dependencies:

    bun install
  3. Setting up environment files

    • Copy the example files to create your environment files:

      cp .env.example .env.example
      cp .dev.vars.example .dev.vars
    • Update the values in both files:

    • .env requires:

      DB_URL=your_database_connection_url
      
    • .dev.vars requires:

      SECRET_KEY=your_secret_key
      DB_URL=your_database_connection_url
      
  4. Run development server:

    bun run dev
  5. Deploy to Cloudflare Workers:

    bunx wrangler login
    bun run deploy

Available Scripts

  • bun run dev - Start development server
  • bun run deploy - Deploy to Cloudflare Workers
  • bun run lint - Run ESLint
  • bun run lint:fix - Fix ESLint errors
  • bun run db:generate - Generate Drizzle migrations
  • bun run db:migrate - Run database migrations

Environment Variables

Required environment variables in .env:

DB_URL=your_database_url

License

MIT License © 2025-PRESENT Musanna AL Akil

About

A TypeScript starter template for building Cloudflare Workers using Hono with Drizzle ORM and Zod validation.

Topics

Resources

License

Stars

Watchers

Forks