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:
- Set up environment variables:
- Copy
.dev.vars.example to .dev.vars
- Add your database URL:
DATABASE_URL=your_postgresql_connection_string
- Run database migrations:
npx drizzle-kit generate
npx drizzle-kit push
- Start the development server:
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 Wrangler
bun run deploy - Deploy to Cloudflare Workers
npx drizzle-kit generate - Generate database migrations
npx 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.
This template is configured for deployment to Cloudflare Workers:
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.