Hono with out-of-the-box support for Cloudflare.
npm i hono-cfimport { HonoCF } from "hono-cf";
import { CF_Bindings } from "hono-cf/types";
const app = new HonoCF({
bindings: {
d1_databases: ["DATABASE_1"],
r2_buckets: ["BUCKET_1"],
hyperdrive: ["HYPERDRIVE"]
} as const satisfies CF_Bindings
})
app.get("/", async (c) => {
return c.text("Hello");
});
app.cron("* * * * *", async (c) => {
console.log(c.env.DATABASE_1) // typed to D1Database
})
export default app;npx wrangler devimport { HonoCF } from "./src";
import { CF_Bindings } from "./src/types";
type Variables = {
db: string
}
const app = new HonoCF({
bindings: {
hyperdrive: ["HYPERDRIVE"]
} as const
}).$type<Variables>()
app.set("db", async (c) => c.env.HYPERDRIVE.connectionString);
app.cron("* * * * *", async (c) => {
console.log(c.var.db)
})Hono Docs