Hono

H

Hono

This is the official Hono discord server for the community

Join

How to set up and use a structured error format?

Hi; I am not strong in API design, and had a question about structuring error formats. I wish to create error formats, that are extensions of the Error instance, let's all it MY_API_ERROR_INSTANCE...

Ensuring Type Safety and Handling Optional JWT Fields in Hono Middleware

Assume I have a middleware created with createMiddleware, which extracts JWT from a cookie and decodes it. After this simple logic, the payload 100% exists. As I've understood from the docs, to pass it further to a handler, I need to use .set('name', value). To add type-safety, I've read that Variables are made for that. First Question: Where do I need to pass these variables? In the root Hono instance of my project? ...

get with params not working

Can someone help me. i have simple code: import { Hono } from "hono"; ...

Can someone explain why types aren't inferred

If I use this code then the types arent inferred whereas with the code in the second image I can
No description

hono logger with log levels

Is there anyway we can use hono logging Middleware the way we use pino js e.g.?

Serialization of Date?

Is there any suggested guidance on how to handle js/json serialization? I ran into an issue using the hono client where the types break due to a Date being typed as a string after being returned from a hono route I see there are no data transformers provided by hono, so wondering what suggestions there are. https://discord.com/channels/1011308539819597844/1248521918554963979...

unit tests with vitest, drizzle and d1

I am having problems running my hono API tests. vites.config.ts ```ts import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config' import path from 'path';...

websocket issue

```ts import { Hono } from 'hono'; import { createBunWebSocket } from 'hono/bun'; import type { WSContext, WSEvents, WSMessageReceive } from "hono/ws";...
No description

Using Hono through Bun inside a Node/Pnpm Monorepo

Hello, I would like to use Hono inside our Turborepo project, but actually we are using pnpm since many said that using bun are not stable enough. It's possible to use and deploy Hono on Bun under that context? I want to avoid the hono/node-server because it has some issues, and the ideal scenario would be able to deploy through Docker this hono instance (using turborepo prune feature)....

c.json() does not enforce OpenAPI return type

Hello there! I'm playing around Hono and RPC, and it works great, but for some reason the return type of the handler function is not enforced by the OpenAPI spec that is provided to it. I have searched on github issues and in here, but did not find anyone with the same problem. It might just be that it's not possible at the moment to do this automatically, but rather I have to type the c.json<ReturnType, 200>() myself ...

Type inference breaks after upgrading hono

(Example image at the end of post) The following code relies on type inference to work. When upgrading from Hono version 4.2.2 to 4.4.3 on both the frontend and backend, the following code broke. 1. I do an rpc fetch like this: ...
No description

ctx.req: readable stream

noticed there's documentation for sending a steam, but having difficulty reading one from the Context

Module not found: Can't resolve 'path' with Hono Drizzle

The Error
./node_modules/dotenv/lib/main.js:2:1
Module not found: Can't resolve 'path'
./node_modules/dotenv/lib/main.js:2:1
Module not found: Can't resolve 'path'
...

unable to retrieve cookie value

```ts // index.ts import { Hono } from 'hono'; import { getCookie, setCookie} from 'hono/cookie'; import CryptoJS from 'crypto-js';...

Posting files in multipart/form-data gives empty string

Hey everyone. I've run into a problem where when I try to upload a file to my hono application as multipart/form-data all I get back is an empty string. In my form I am sending a key of name expected to be a string and image expected to be a file....
No description

[zod, bun]#openapi async/await doesn't work

This ossue was previously on https://discord.com/channels/1011308539819597844/1012485912409690122/1242558525012709539, but I was advised to open it here. here is a noob question. Im quite new to TS, bun and Hono with Zod. I cant make sense of why TS is screaming at me in the first line with async ```ts apps.openapi(routeGetApp, async (c) => {...

where cookies??? where res?

Hi everyone, I'm not using cookies at all, or trying to mess with the headers myself and am getting this error in a POST handler: [NOTE]: i'm porting this from express to hono and the logic hasn't changed and this has been working forever (in express) [ALSO]: the user is created in the database, the email is sent and received... this is my code:...
No description

How to debug Hono/HonoX in Visual Studio Code?

I always run the code via npm run dev or bun dev. Since I am building a web app in HonoX and most of it is SSR, how can i use the IDE debugger so I can hit breakpoints and etc in Visual Studio Code? Ex: next.js has this guide: https://nextjs.org/docs/pages/building-your-application/configuring/debugging How do I do this for Hono/X?...

Does the context object get shared across all sessions?

I am using hono-sessions. I have several different users. Am I correct in assuming that each invocation in hono shares 1 context object ... so if I store something directly using context.set(x, y) it will be shared by every route?

middleware on a router level

Right now, i have this setup, where canExperiment is also a middleware: ```javascript export const statisticsRouter = new Hono(); statisticsRouter.get('/monitor', monitorHandler);...