A modern, high-performance backend starter template built with Hono, featuring PostgreSQL integration with Drizzle ORM and deployment ready for Cloudflare Workers.
- Hono Framework: Ultra-fast web framework for edge computing
- Database Integration: PostgreSQL support with Drizzle ORM
- Type Safety: Full TypeScript support with Zod validation
- Edge Ready: Configured for Cloudflare Workers deployment
- Migration Tools: Database migrations with Drizzle Kit
- Modern Stack: Uses latest versions of all dependencies
- Bun Runtime
- Node.js (v18 or later)
- PostgreSQL database (I recommend Neon for serverless PostgreSQL)
- Cloudflare account (for deployment)
- Clone the repository:
git clone https://github.com/michaelshimeles/hono-backend-sync
cd hono-backend
- Install dependencies:
bun install
- Set up environment variables:
- Copy
.dev.vars.example
to.dev.vars
- Add your database URL:
- Copy
DATABASE_URL=your_postgresql_connection_string
- Run database migrations:
npx drizzle-kit generate
npx drizzle-kit push
- Start the development server:
bun run dev
The server will start on http://localhost:8787
hono-backend/
├── src/
│ ├── index.ts # Main application entry
│ └── db/
│ └── schema.ts # Database schema definitions
├── drizzle/ # Database migrations
├── .dev.vars.example # Example environment variables
├── drizzle.config.ts # Drizzle ORM configuration
├── migrate.ts # Migration script
├── wrangler.toml # Cloudflare Workers configuration
└── package.json
bun run dev
- Start development server with Wranglerbun run deploy
- Deploy to Cloudflare Workersnpx drizzle-kit generate
- Generate database migrationsnpx drizzle-kit push
- Create table(s)
The starter includes a sample products table with the following schema:
products {
id: serial (primary key)
name: text
description: text
price: double precision
}
GET /
- Fetch all products from the database
All endpoints use Zod for request validation.
- Hono - Web framework
- Drizzle ORM - Database ORM
- Neon Database - Serverless PostgreSQL
- Zod - TypeScript-first schema validation
- Cloudflare Workers - Edge computing platform
- Bun - JavaScript runtime & package manager
This template is configured for deployment to Cloudflare Workers:
bun run deploy
Make sure to set up your environment variables in your Cloudflare Workers dashboard.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.