Hono DO is a wrapper of Cloudflare Workers ' Durable Object, designed for Hono.
Important
Cloudflare released RPC feature, which is a better way to communicate between Durable Objects. This library was developed to improve the developer experience for Durable Objects when RPC was not yet available. So, please consider it before using this library.
$ npm install hono-do
export const Counter = generateHonoObject("/counter", async (app, state) => {
const { storage } = state;
let value = (await storage.get<number>("value")) ?? 0;
app.post("/increment", (c) => {
storage.put("value", value++);
return c.text(value.toString());
});
app.post("/decrement", (c) => {
storage.put("value", value--);
return c.text(value.toString());
});
app.get("/", (c) => {
return c.text(value.toString());
});
});
You want to find more? Check out the examples!
This project is open for contributions. Feel free to open an issue or a pull request! Contributing Guide for more information.