- Runtime: Cloudflare Workers
- Framework: Hono.js (Modern, fast web framework)
- Database: MongoDB (With native Node.js driver)
- Deployment: Wrangler
- Types: Cloudflare Typegen
- Clone the repository:
git clone https://github.com/thedhruvish/hono-mongodb.git
cd hono-mongodb
- Install dependencies:
npm install
- Configure environment:
- Create
.dev.vars
file in root directory:
MONGODB_URI="your_mongodb_connection_string"
- Create
npm run dev
- Set production secrets:
npx wrangler secret put MONGODB_URI
- Deploy to Cloudflare:
npm run deploy
Sync Cloudflare bindings with:
npm run cf-typegen
src/
├── db/ # Database connection logic
├── routes/ # API endpoint handlers
├── types/ # TypeScript type definitions
└── index.ts # Main application entry
MONGODB_URI
: MongoDB connection string- (Production) Set via
wrangler secret put
Feel free to fork the repository and submit pull requests. For major changes, please open an issue first to discuss what you would like to change.
MIT License - See LICENSE