This guide is for those who might be using bhvr and want to deploy their Hono server to a Cloudflare worker. While it's relatively simple to setup I will be looking into how to automate it into the CLI setup.
- Install type dependencies to the
server
repo and update theserver/tsconfig.json
file.
bun add @cloudflare/workers-types
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": ["bun-types", "@cloudflare/workers-types"],
// rest of the config...
}
- Add a new file called
wrangler.json
to the root of yourserver
directory and put in the following contents
{
"name": "bhvr-server",
"main": "src/index.ts",
"compatibility_date": "2025-02-13",
"compatibility_flags": [
"nodejs_compat"
]
}
- Login to Your Cloudflare account with the Wrangler CLI
bunx wrangler login
- Deploy
bunx wrangler deploy --minify
Optional: Create a new script in package.json
to automate deployments
"scripts": {
"dev": "bun run --hot src/index.ts",
"deploy": "wrangler deploy --minify"
},
Feel free to contact me if you have any questions or concerns!