Hono

H

Hono

This is the official Hono discord server for the community

Join

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

Can app.notFound be customized for each Hono instance?

Hi. I'm experimenting a small application on Node.js 20. I notice that the app.notFound() function is applied globally rather than per Hono instance. For example: ``` import { Hono } from 'hono'; import { serve } from '@hono/node-server';...

Context is not finalized

`` <-- GET / Error: Context is not finalized. Did you forget to return a Response object or await next()`? at file:///workspace/react-router/node_modules/.pnpm/[email protected]/node_modules/hono/dist/hono-base.js:202:17 at getRequestListener.overrideGlobalObjects (file:///workspace/react-router/node_modules/.pnpm/@[email protected][email protected]/node_modules/@hono/vite-dev-server/dist/dev-server.js:78:32)...

Git Autodeploy on Cloudflare

Hi! I've build an API with Hono via Bun + CF Workers. On the docs they have a section where they explain how to make auto-deploys to cloudflare on branch pushes via GitHub Actions. I've seen that cloudflare workers, they now have an option where you can connect to the repository, select the branch, the compilation command and the implementation command. When I deploy the worker from the CLI I use the command "bun run deploy:main" that runs "wrangler deploy --env main --minify src/index.ts". I have setted this last command on the implementation command but It gives an error on the deployment....
No description

Is there any way to mock cookies using testing helpers?

we already have testing helper and cookies helpers in Hono, but I can't find a way to inject cookies. I'm using Lucia with Hono together, they recommend to transfer session by cookies. Is this possible in test environment? if no, I have a worst plan is to create a custom app and takeover routes. and replace cookie middleware with bearer token middleware. how do you think?...

Is there a way to get bindings outside the `c` Context of an inbound Request in Cloudflare Workers?

I'm trying to setup the better-auth with D1 but following the guide it pops out that I need to have a valid reference of my binded D1 database outside of the inbount request context (the c.env). There are other examples of using D1 with better-auth but I can't figure out how to make it work within a Hono app deployed on Cloudflare Workers. ```typescript import { betterAuth } from "better-auth";...

Multipath route parameters in Hono

How can I express a "multipath segments" in Hono? I'm trying to use Hono for the Cloudflare Pages Functions -> Workers transition and I have a route like this: functions/[[app]]/[hash].zip.ts // e.g. /my-app/nested/path/12345.zip // -> app: ["my-app", "nested", "path"]...

Vite plugin does not compile the commonjs module

Hey Team, I am developing an application using Yusuke's template https://github.com/yusukebe/cloudflare-d1-drizzle-honox-starter If you add any library which also comes with commonjs/nodejs module, it fails to load them . Everything works fine with npx wrangler pages dev though. Any idea, agains which repo, should I post this issue on Github...

Pass context to exception handler

Hey, is there a way to pass some context about request to the exception handler via Hono context?