Skip to content

Can we use hono stacks with Durable Objects? #1707

Closed Answered by ShravanSunder
ShravanSunder asked this question in Q&A
Discussion options

You must be logged in to vote

i've created a simple local helper for myself. The rpc client is fully typed to be used with durable object.

Here's what i have.

// hono type from DO class
export type DistributedLeaseHonoController = typeof DistributedLease['prototype']['app'];
// helper
import { type DurableObjectNamespace } from '@cloudflare/workers-types';
import { type Hono } from 'hono';
import { hc } from 'hono/client';

import { getDurableObjectFromName } from '~~/helpers/getDurableObjectFromName';

export const createClientForDO = <THonoType extends Hono>(params: {
	dObj: DurableObjectNamespace;
	idString: string;
	origin: string;
}) => {
	const stub = getDurableObjectFromName(params.dObj, params.idString);

	const 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ShravanSunder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants