Skip to content

manolo-in/hono-cf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cover

Hono-CF

Hono with out-of-the-box support for Cloudflare.

Installation

npm i hono-cf

Usage

import { 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;

Run

npx wrangler dev

Variables

import { 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)
})

Resources

Hono Docs

About

Hono with out-of-the box support for Cloudflare 🔥

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published