Hono

H

Hono

This is the official Hono discord server for the community

Join

Can't get serveStatic to work with `root`

I'm a bit confused here: app.use("/static/*", serverStatic({ root: "./static"})) can't resolve /static/myscript.js But app.use("/myscript", serveStatic({ path: "./static/assets/myscript.js"}) does work when accessing /myscript ...

How to accept flattened objects in query params?

It seems that the hono client calls String() on the query params so that any objects passed through which should normally be something like filters[key]=value ends up becoming filters="[object Object]". 1. I'm pretty sure this use-case should be supported since it appears out in the wild when using query params 2. Is there a way to make this work? or is the recommendation to go with flat query objects / honojs client doesn't support objects in query params? ...

The hc function returns an unkown type

When I hover over the hc function I see this typing:
hc<Hono<BlankEnv, BlankSchema | MergeSchemaPath<BlankSchema, "/api/auth">, "/api/">>(baseUrl: string, options?: ClientRequestOptions): unknown
hc<Hono<BlankEnv, BlankSchema | MergeSchemaPath<BlankSchema, "/api/auth">, "/api/">>(baseUrl: string, options?: ClientRequestOptions): unknown
The type of the route seems to be correct, what am doing wrong?...

Passing types along from Hono to Next

We are exploring using Hono as a BFF for our next.js app, which works well in our monorepo, however the types generated on the Hono server are not being passed over the wire to next.js. Can anyone point me in the right direction of what to explore. hono server which has data typed correctly. ```...

Why does .openapi(route, handler) return unknown type in client.ts when using OpenAPIHono?

I’m new to Hono and trying out @hono/zod-openapi for the first time. Im trying out the RPC feature with client.ts I noticed that when I define my routes like this ...

Passing `{...rest}` in the html`` tag

https://hono.dev/docs/helpers/html shows how you can use the spread operator to pass a bunch of generic props to a tag, but using JSX. We're all in on the html tagged literal, and I was wondering if its possible to do this using it? something like: <div ...${rest}>?...

client of type unknown

I am having issues with the type inference of the client when using hono rpc I've read https://hono.dev/docs/guides/rpc, https://hono.dev/examples/grouping-routes-rpc, and https://github.com/honojs/hono/issues/3148 and have adjusted my code accordingly, but am still getting this issue please see my hono code: https://github.com/picafe/cs-ia/tree/hono/backend/src/routes and https://github.com/picafe/cs-ia/tree/hono/backend/src/index.ts client is here: https://github.com/picafe/cs-ia/blob/hono/client/src/lib/client.ts apologies in advance for my terrible code ...

Got `unknown` type on res.json() on a OpenAPI RPC route

Hey ! I have an issue with RPC client and OpenAPI route inference. Reproduction : https://stackblitz.com/edit/vitejs-vite-lqsp6pho?file=index.ts ```tsx...

Using honox client.ts to load web components

I'm using honox client.ts to load web components I created in Lit. It works great but only when I have at least one island on the route. How can I make sure the js is loaded even when I don't have island on the route. I'm using <Script src='/app/client.ts' async /> in my _renderer.tsx file`...

RPC client shows 'any'

Hi, I currently working on getting frontend api with types. But when I do it, it shows `` Element implicitly has an 'any' type because expression of type '":shift_date"' can't be used to index type 'ClientRequest<{ [x: $${Lowercase<string>}]: { input: any; output: any; outputFormat: string; status: StatusCode; }; }>'. Property ':shift_date' does not exist on type 'ClientRequest<{ [x: $${Lowercase<string>}`]: { input: any; output: any; outputFormat: string; status: StatusCode; }; }>'...
No description

Handler type

Hey guys was wondering, what is the best way to implement a RouteHandler like the one present in @hono/zod-openapi based om my code below, I am using hono-openapi for .lazy() and a couple other features

Node Web Sockets in Hono

Hello all, I'm fairly new to Hono and I've recently picked it up for some of my projects and enjoyed it very much. Im currently facing problems with one of my projects that uses WebSockets to communicate with Hardware boxes. And I will need another WebSocket as well to communicate with my frontend and mobile application. I've searched for many solutions online but it looks like Hono with Node WebSockets is rarely talked about....

Types issue in zod-openapi in v0.19.4, .5, & .6 (repro attached)

Maybe I'm holding it wrong, but this minimal file reproduces the type error: ```ts import {OpenAPIHono, createRoute, z} from '@hono/zod-openapi' interface AppBindings { Variables: { userId: string } }...

Which Hono Router Should I Use in This Case?

Hono has five different routers: 1. PatternRouter 2. SmartRouter 3. LinearRouter...

zValidator c.req.valid("form") type error

Hey everyone, I am trying to use the zValidator middleware which I have setup in an auth.validator.ts file which looks like: ``` const signUpSchema = z.object({ email: z.string().email("Invalid email address"), password: z...

exemple for zod-openapi + rpc

does anyone has a working exemple of https://hono.dev/examples/zod-openapi + https://hono.dev/docs/guides/rpc i know i have to chain routes, but i still got unknown (maybe because of zod-openapi ?)...

@vitejs/plugin-react can't detect preamble

i'm trying to get a basic hono/react project working, and i get the above error on the client. i'm working from the following example repo, but i'm modifying it for bun: https://github.com/yusukebe/hono-vite-react-stack/tree/main/examples/basic i know i came across a note about this somewhere, but i can't find it now. the issue linked to by the error isn't especially helpful (for me), and at a glance it appears resolved: https://github.com/vitejs/vite-plugin-react/issues/11#discussion_r430879201...

Hono Client Double-Prefixing Issue

I'm running into a problem with my Hono-based project. On the server, I've set up a base path with: app.basePath('/AdminApi'); so all routes (like /AdminApi/test) are automatically prefixed....
No description

How would you pick between Hono + Client Components vs Hono + React (and with or without HonoX)?

I'm using Hono currently along with Datastar, which has been conceptually great but Datastar is just maybe one tick too immature for my current needs. Hono has been great, so I want to stick with that. Our team knows React reasonably well, so we're leaning that way (and client components would fit just fine), but we're not tied to it. It seems that we have a few choices:...

hono aws lambda 404 issues

I found hono while doing to experimenting with better-auth js and have been testing with it recently. I want to build a hono API in aws lambda for my projects so I can pay per usage instead of provisioning a server to start. I am running into an issue where I am receiving a 404 code back from my API gateway, although the lambda function is being hit with what I assume is the correct path. Although I guess it can't be if I am getting a 404? Anyway, I am attaching the github repo for the AWS CDK build. I am hoping someone can help me figure this out? Please message me if you have run into something similar. Some AI suggested solution mentioned that the stage of the API gateway might be the issue. Basically the "prod" in https://xxxx.execute-api.us-east-1.amazonaws.com/prod/some-path could be getting in the way of the path hono is looking for? I wasnt able to find a solution to this issue though, and when i tested adding the "/prod/..." to the app.get() argument, I still got the 404. ...