Hono

H

Hono

This is the official Hono discord server for the community

Join

Have you guys ever gotten websockets to work on Hono + `@hono/vite-dev-server` plugin?

This occurs for Bun and Node. 1. On Bun, I can serve websockets using import { createBunWebSocket } from 'hono/bun'; https://github.com/honojs/vite-plugins/issues/148 2. On Node, I can serve websockets using ws and import { serve } from '@hono/node-server' ...

status 200 with empty JSON

I am not logged in when doing the api call from my vs code but it's not returning unauthorized 401 but a 200 with an empty json? ```// Fetch all workflows .get("/", clerkMiddleware(), async (c) => { const auth = getAuth(c); ...
No description

How to do filepath as a param in an RPC route?

Hey, I'm trying to fetch a file/folder with an RPC route and want to add the filepath to the URL as a param, but this doesn't work because then I get a 404. Example: /api/folders/:filepath -> /api/folders/foo/bar/baz ...

How to use custom fetch method for Hono client?

I have a noob question. I used to use the axios library and want a similar experience with the Hono client, such as shorter syntax, automatic JSON transformation and interceptors. Some suggest using ky instead of axios, but I don't know how to integrate it. The documentation (https://hono.dev/docs/guides/rpc#custom-fetch-method) is unclear to me. Could I get any guidance or example code?

Losing type information on Client for AppType

I'm getting output: { [x: string]: any; result?: any; }; on the client but server is showing correct type. I have strict true on the client lib.
No description

All GET/POST api calls returns Internal server error 500

I'm using Hono for my app https://platform.procureezy.com/workflows but it keeps returning this error for all my API calls : GET https://platform.procureezy.com/api/workflows 500 (Internal Server Error)
[[...route]] ```app.onError((err, c) => { if (err instanceof HTTPException) {...

TypeError: Response constructor: Invalid response status code 204

Hi, I seem to be getting the following error on the latest version of Hono when using any 2XX status from 204 and above. It is ocurring when I set the context status using c.status(2XX) before I return a JSON response.

@hono/zod-openapi: How to write OpenAPI doc for middleware responses?

I have an auth middleware which will check if the api token is provided in the request header, so it will respond with 401 or pass. How to make sure every protected route will be applied with the 401 response? ```typescript app.openapi(...

Experimenting with custom NextJS Server

Hey guys, I'm running into an issue where nextjs is not hydrating properly and hono is giving an error: unhandledRejection: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client Here's the code: ```ts...

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