Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

sor4chi/hono-do

Open more actions menu

Repository files navigation

Hono for Durable Object

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

Usage

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!

Support

License

MIT

Contributing

This project is open for contributions. Feel free to open an issue or a pull request! Contributing Guide for more information.

About

A wrapper of Cloudflare Workers's Durable Object for Hono.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.