Hono

H

Hono

This is the official Hono discord server for the community

Join

Module not found '.../index.ts' with Bun

Hi everyone, I just created a fresh hono app and using Bun as a package manager. When I run bun dev it initally works fine until I hit save on the index.ts file then I get an error error: Module not found '<path-of-project>/src/index.ts. The only way I can get it back to run is to restart the process completely... Has anyone encountered this issue and is there any way to fix it?...

getSetCookie is not a function

I've upgraded a Workers project by bumping Hono and Wrangler by a few minor versions. In staging, I'm now seeing:  "TypeError: this[#res].headers.getSetCookie is not a function"  in my streaming logs. This didn't exist before....

any option to have $post ignore json when we provide body via init: {body.. ?

``` const resp = await client.api.scheduling.scheduleExecution.$post( {json: execution}, // this is not used {init:{body: jsonAsString}} );...

any way to have different .notFound depending on parent path ?

I have 2 main path: api dashboard I would like anything path under api/.... that do not exit to return a json object ...

NotFoundHandler TypeScript Error

I am getting a typescript error that I just don't know how to resolve and looking for some help to why I am getting the error. I have created a custom notFound handler function and I am adding it to my app. ts file notFound.ts...
No description

adding generic error output type to App type

Hey all, I am using the typed RPC feature of hono and got it working, except for the errors I have an .onError that consstruct a json from error thrown and I would like that error type to be unioned with each of the output type of all path Is there a way to do this ?...

Hono not matching routes

Hi, I’m using hono as my backend server, however it’s not matching routes… everything gets passed to my notFound handler. ```js import { Hono } from "hono";...

Response loses type when specifying type arguments manually

Hi there! Just started messing around with Hono and was trying to optimize for typesafety. The docs state that adding the path as a generic parameter can help with type inferencing https://hono.dev/docs/guides/rpc#specify-type-arguments-manually so I gave this a shot...

Zod validator not working

I'm following the tutorial here to set up Hono with Zod validation, but I'm getting the type error seen in the screenshot. Below is my code. import { type Context, Hono } from "hono"; import { zValidator } from "@hono/zod-validator"; import { z } from "zod";...
No description

c.req.param() not work when using middleware combine

hi all, I can't get params inside "every" middleware, but it works in "some" middleware. is this a bug? how can i get params inside every? ```ts export const m = (action: string, field: string): MiddlewareHandler => every(...

How to perform an async operation in Web Socket's onMessage?

I'm using Web Sockets with Bun, and wondering what's the idiomatic Hono-way of awaiting a Promise in onMessage (which is a sync method)? ``` const { upgradeWebSocket, websocket } = createBunWebSocket<ServerWebSocket>(); new Hono().get(...

Hono RPC TypeScript error

Hey I'm getting a really frusttrating error where TypeScript is not inferring types in a monorepo. I'm building a monorepo using Nextjs for the frontend and bun & hono for the backend. I'm trying to use hono rpc and I'm exporting the type of my router like this in my app.ts file in my backend project: import createApp from '@/lib/create-app' import configureOpenAPI from '@/lib/configure-open-api' import index from '@/routes/index.route'...

How to prevent Server Error if no req body?

Hi I have this code: ```ts userRouter.patch("/self", async (c) => { const reqUserId = c.get("authUser").user?.id;...

are there any way to check whether route exists in the router or not?

i want to create more strict WebSocket adapter for Hono on Node. the current one @hono/node-ws upgrade every websocket connection even if route isn't exists. i want to reject those connections. are there any reliable way to check whether route exists in router or not? even if onError or onNotFound handler has been set up to return success response. my current solution to reject invalid websocket connection is to set up catch all route, added it as the last handler and in onOpen callback, close those unwanted connection. this works fine, but it would be better if it reject the connection from beginning instead of upgrade it and then close it later....

AppRouteHandler

Incorrectly inferred types. Hi. I have started working with Hono (with bun). I'm using drizzle as amy ORM. I have setup my project based on the hono startup project (https://github.com/w3cj/hono-open-api-starter/blob/main/package.json). ...
No description

Next.js 15.0.0 "FetchEventLike" type error

Hi, I’m trying to use Hono with Next.js 15 App Router and Auth.js. Everything works fine when I run pnpm dev, but when I run pnpm build, I encounter a type error (screenshot attached). ```...
No description

Append Authorization access token to RPC client in asynchronous way (amplify auth/cognito)

Im trying to use RPC but I use AMPLIFY AUTH and i want to append the access token in each rpc clients. ```ts const client = hc<typeof adminApp>(process.env.NEXT_PUBLIC_API_URL!, {...

Infer client openAPI

Hey all, I am wondering about something, I am able to infer the types from hono, in the client side if it's just a normal hono app without openAPI, but the moment i add open api, i do not get any inference, does any one know a workaroud or a way to get inference in the client
No description

Envs not extendable with `createFactory`

When utilizing the createFactory method, middleware is unable to modify or extend any of the types. This seems like a bug/issue as any auth middlware would want to ensure a session/user variable would be defined for type safety. factory.ts ```ts export type HonoEnv = {...
No description