Hono

H

Hono

This is the official Hono discord server for the community

Join

Update the default validator to return custom error response

hey guys, I want to update the default zValidator of hono to return custom error objects. Right now, it returns something like this: ```json { "success": false, "error": {...

Get the username using basic auth

```jsx import { Hono } from 'hono' import { basicAuth } from 'hono/basic-auth' const page = new Hono()...

deno: react-pdf pitfall

If you are using deno+hono and react-pdf to create pdfs, do not use the default import like the docs of react-pdf say. Instead of ```typescript import ReactPDF from "@react-pdf/renderer";...
No description

correct type of this `Context`

from here https://hono.dev/docs/middleware/builtin/timeout#usage I tried ```ts context: Context<{ Bindings: Env }>...
No description

Honox scripts and styles not working in production

Hi Guys, Am currently trying to deploy a honox project in Deno deploy. The project is working well in the local machine but when deployed the islands and styles are not working. It might be a path issue but am unsure on how to proceed. _renderer.tsx ```...

Typing nested controlled

Hi, how can I get this param typed? ```typescript import { Hono } from "hono" // reviews controller...

How to handle file uploads

There's a very brief documentation on file upload, however it doesn't cover how to store files on the disk. Of course I could use native Node modules, like fs however my biggest problem is that it's all done in memory. I've also noticed that when using req.parseBody, if there are multiple large size files being uploaded, the server response time for other endpoints increases drastically. So what would be the correct way to handle file uploads, while avoiding storing files in the memory?

products/{id} APIs conflicting with products/my-products in generated doc with OpenAPI

I did put the {id} one after the my-products one, but it doesn't seem to work?
No description

Failed deploy with Hono, Vite and email event handler

I'm building a email disposable service with Cloudflare workers. When I deploy using vite build --mode client && vite build && wrangler deploy --no-bundle I get the error: A request to the Cloudflare API (/accounts/xxx/workers/scripts/disposible-email/versions) failed. Uncaught TypeError: Cannot read properties of undefined (reading 'map') at null.<anonymous> (index.js:1:21247) in route [code: 10021]. I already figured out that the problem lies with export default { fetch: app.fetch, email: async (message, env) => {} because when I export app like export default app the error does not occur. When I use export default { fetch: app.fetch } the error will occur. My entrypoint (index.tsx) looks like this:...

Why Are My Hono RPC Routes Not Showing Beyond $get, $post, and $url?

I have set up RPC in my Hono project and configured my routes as follows. However, when I check the available RPC methods, only $get, $post, and $url appear in the list.
How can I make all the other defined routes accessible through RPC? Here is my current router setup:...
No description

How to pipe the archive in stream hono?

```js const streamPipe = new PassThrough(); archive.pipe(streamPipe); const write = new WritableStream();...

Hono React with bun

Error: ``` Type '(props: Props) => boolean' is not assignable to type 'FC'. Type 'boolean' is not assignable to type 'HtmlEscapedString | Promise<HtmlEscapedString> | null'.ts(2322)...

Cannot resolve React with hono/jsx

My application is getting errors when trying to use jsx. My project uses monorepo structure managed by Nx. The way it's managed (default) is to have three tsconfig.*.json files in each folder: - tsconfig.json which references two other configs (see below) via project references. It extends root TS config which contains its own compilerOptions - tsconfig.lib.json settings for production source code, this is where you usually put compilerOptions specific settings and configuration relevant to source code for production (excludes tests etc) - tsconfig.spec.json settings for testing code, this means files ending with *.spec.ts{x} are included by default...

Hono WebSocket Helper Cloudflare

Hello, i want to make a chat app using WebSocket Helper... but im having a hard time to comprehend how to divide it into chat groups and broadcast to them...(since theres not "onOpen") I rawdogged it using a receiver... but i assume using the WS Helper is more idiomic. Any suggestions? ...

Hono Help with Cloudflare Workers

Hello, this is Patrick and I am experienced developer in backend but just dive into Serverless architecture with Cloudflare workers. I'm looking to learn how to use Cloudflare Workers with Hono.js, Prisma to build website. I need to make basic environment asap to finish my task. Thanks....

Factory app creation

Hi, I'm building a backend using Hono and am splitting up my routes into groups, for example '/authors', and '/books'. Each group is written in a separate file and then imported to the main Hono app which will serve the app. Right now I have authentication middleware on the main app and in that middleware the "user" context is set so we can access the current user on the routes below, however since the "books" and "authors" sub-apps are imported to the main app from a different location they don't have access to the context set by the middleware in the main app. In the "books" app I want to be able to access the "user" context from the middleware. What is the recommended way of doing this? nb: It seems like createFactory().createApp() was the recommended way to do this, however this seems to be deprecated?...

RPC typing is behaving weird

I'm not sure if this might be an issue with my setup or with Hono itself, but I'm a bit at a loss here I have a Hono router for projects which I want to use as a projectsClient with hc. For this I take my projects Router and extract the Type like this: ...

Are middleware singleton like in ElysiaJS ?

Hello, Just wondering if middleware were singleton like in Elysia ? I have a middleware which is my dependency container, and I need to apply a .use(container) on each route which needs to access the container. Should I add a check in my code to not add my variables to context if it already been added ? Or does Hono do this for me with a specific option ? Thx for your answers 🙂...

Extract routes from hono definition

Hi everyone, i want to extract all the routes from hono definition for example : ```ts export const app = new Hono<Env>() .route('/transactions', transactionsRoute);...
Next