Hono

H

Hono

This is the official Hono discord server for the community

Join

streamSSE onAbort never triggered

maybe I'm missing something obvious, but this never logs "disconnected" when I close the sse connection. ```typescript import { serve } from '@hono/node-server' import { Hono } from 'hono'...

Hono tRPC Server body issue

I have been trying to get Cloudflare Workers, Hono and tRPC working for tens of hours now. I am using the @hono/trpc-server package which gives me middleware for trpc to run with hono. They even have an example with cloudflare workers and a d1 database, so I know it is possible to do what I am trying to do. The problem I am having is that tRPC is not reading the body properly, or at all. Take this function as an example: ```ts...

Server Side Events connection with AI sdk dropped on safari mobile

One issue we are constantly facing is that our AI stream is getting dropped by safari often. So users would start an AI response, put the tab in the background and come back to a broken response.

Tracing and opentelemetry

Hi! The Hono doc with Pino integration suggests setting a requestId or reqId field on the logger to do tracing. Is that the same as the HyperDx / opentelemetry "trace_id" field? Or is that different? should both be using the same value / field? how do you recommend setting hono+pino+otel observation?...

Hono for Large Scale Apps

Hello, We have decided to use Hono as our API framework for our new web app. We have used it for a few months now and finding it fantastic. My only confussion is since the start, I had the typical controller, service and repository structure. I recently discovered on the Hono documentation that they do not recommended the typical 'RoR' controller pattern. I completley get the reason, but would like to know of examples of how people are building apps with many routes and how they are splitting up their business & database logic. Thanks...

RPC types not working with imported Zod Object

Hi, When using Hono with RPC for inferring types on endpoints I have encountered a strange behaviour. Post payload & return types are working if I use z.object(), but not an imported z.object() (I call it TestSchema in the example below). I don't want to redefine types in two places, is there any way I can have an imported Zod Object in zValidator that gets inferred to the client with RPC? This works: ```ts...

How to not break type inference with middleware?

Hey eveyone, when doing something like this: ```ts const orgsRoutes = new Hono<AuthedContext>() .post('/', zValidator('json', createOrgFormSchema), async (c) => { // create org logic...

How to properly type Variables bound to the context?

I read that I can set a variables with c.set(...) and I also noticed there is a generic type for that. However, I can't get it to work why I customize the type. I want to say that I have a variable myVar bound which is of type MyClass. How can I achieve that?...

How to respond (acknowledge) a request without returning?

with express I can do res.send() and continue logic afterwards. How do I do that wioth hono?

Using hono with bundlers (tsup)

Is it possible to avoid the "Module 'hono' declares 'Hono' locally, but it is not exported" when using moduleResolution set to bundler? The only configuration I've found to work is strict ESM: * "module": "nodenext" * "moduleResolution": "nodenext"...

Help setting up Hono RPC types between backend and Expo client

Hey, I’m using Hono for my backend and React Native (Expo) for my client, and I’m trying to set up Hono RPC with type safety shared between the two. Here’s my project structure: ``` project/...

Hono RPC Type Inference Issues with Nested Routes in Monorepo

Hi everyone! I'm fairly new to Hono and still learning, so I apologize if I'm missing something obvious or doing something wrong. I'm working on a monorepo project using Next.js (frontend) and Hono (backend) with Hono RPC for type-safe API communication. I'm experiencing issues where some API routes are not properly typed on the frontend, possibly due to deep nesting in the type definitions. Project Structure: - Monorepo: pnpm workspace - Backend: Hono (apps/api) with RPC support...

The recommended way to get the raw request body

There is await c.req.text() but idk about that. I know how to do it in express (req.rawBody) but it's kinda unintuitieve for Hono. So what do I do?

react ssr with bun vite and hono

I'm having trouble with @hono/vite-dev-server. The Vite instance isn't being set in Hono's context. My vite.config.ts: ```ts export default defineConfig({ plugins: [...

RPC, nested routing and types

Hi everyone, quick question given the attached example: - How do you avoid losing RPC typing when doing nested routing with different routes? Example /api/stores/:storeId/products. The storeId is not required in RPC because productsCollectionRoutes doesn't have the routing context of storesRoutes. - It would be less verbose to declare routes with :id instead of :productId, but I guess that's wouldn't work in RPC as I would have two ids? As you can see, I have different routes like:...

Beginner: infer context type

Hey everyone, this might seem like a simple question but I couldn't find an answer online for it. In the following snipet how could I change the type of session from (Session | null) to (Session) since I have a middleware that checks if it's null before the controller ? here is the code:...

`c.req.json()` makes my POST endpoint hang and timeout

Setup: - Vercel serverless functions, Node.js runtime - @hono/vite-build, vite-config.ts: ```TypeScript {...

hono with better-auth

It should be a pretty straightforward setup, all I'm trying to do here is get the basic authentication working with better auth, I have the schema generated and everything but I keep having issues actually hitting the /api/auth routes. Any idea why this might be an issue? This is my setup:...

swagger-ui and @hono/zod-openapi mismatch

Hello, I'm trying to make the swagger-ui middleware work with the @hono/zod-openapi package. It does work when I run my project but I get this deno-ts error in VS code and I wondered if it was possible to solve it?
app.use("/ui", swaggerUI({ url: "/api/docs" }));
app.use("/ui", swaggerUI({ url: "/api/docs" }));
...
Next