Hono

H

Hono

This is the official Hono discord server for the community

Join

struggles with routing with file extensions after optional path parameters

hey! trying to figure out how to come up with the correct route definition for my use case. this is what i have now: /:one/:two/:three/:four?{.+\\.png$} ...

Hono is not working on netlify (Function crashed)

Hey! I'm totally new to hono. I tried to use hono for netlify but it's not working. here's all the code: netlify/edge-functions/index.ts ```js import { Hono } from 'jsr:@hono/hono' import { handle } from 'jsr:@hono/hono/netlify'...
No description

How to Resolve "Argument of type MiddlewareHandler Error"

The lines of code where I used zValidator throws the error "Argument of type MiddlewareHandler Error". Here is the code snippet of how I am using the validator. `jobRouter .route("/") .post(...

How to resolve relative routes

I have a sub-router like this ```tsx .get( '/', basicAuth({...
No description

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';...