Hono

H

Hono

This is the official Hono discord server for the community

Join

Get the user IP address

Is there no better way to get the user IP address than doing this 👇🏽? https://github.com/EdamAme-x/deno-deploy-hono-ip/blob/main/entry.ts It works, but it's a bit convoluted. FYI, I use the IP address to implement a rate limiter....

Hono JS best practice for DRY

What are the best practices in Hono for writing APIs, specifically when one API (API B) partially replicates the functionality of another API (API A)? For example, if API A performs a specific task, and API B performs a different task but includes a part that is identical to the task in API A, what is the recommended approach to handle this overlap efficiently and maintainably?

hono/jsx/dom not re-rendering on state change

hiii, can someone tell me if i'm doing something wrong with client side rendering/hydration using hono/jsx/dom? it seems to mount and render properly but then state changes don't cause it to update. onClick={() => alert('...')} works as expected but onClick={() => setState(...)} does nothing, nothing in the console and no action. useEffect also does nothing. i think i followed the Client Components page pretty closely this is the component in question, it's rendered on both the client and server ```ts import { useState } from "hono/jsx";...

JSX Element type

I have a JSX component which should accept multiple children as props, however, using Element | Element[] (or ReactElement imported from hono/jsx) gives the following error when multiple children are passed: ``` Type 'Element' is not assignable to type 'ReactElement'. Type 'HtmlEscapedString' is not assignable to type 'ReactElement'....

middleware redirect from HTTPS to HTTP

I have set up this middleware to run on all my authenticated routes : (simplified version) (notice the commented lines setting the protocol) ```javascript export const orgAndWebsiteMiddleware = async (c, next) => {...

Synchronous function returns no value unless await

Hello everyone, I'm encountering a confusing issue while working with Hono.js. In my project, I have a function named getEbayAuthUrl which is not defined as an async function and simply returns a string, e.g., "hi". However, I've noticed that if I do not use await when calling this function, the value doesn't seem to be processed correctly, as if it were missing in subsequent database operations. Here's a simplified version of the function:...

Using Vitest with Hono JSX // Error: Expression expected

Hi there, I'm trying to add vitest to a hono project (I've not used vitest before) and am running into a problem... The following code works fine in the browser -- hitting root on localhost shows a page with an H1 of "Hello world"....

Problems with Form POST in Safari and IOS

I have this simple router, relying on a simple HTML form. ```javascript export const authSigninRouter = new Hono(); const SigninForm = ({ email = '', errors }) => {...

Can the queue only be defined in the root?

When writing a Cloudflare queue with Honojs, it seems the queue needs to be exported as part of the default. This default export cannot be mounted in another route path. Do all queue handlers need to be exported from the root?

Hono-Sessions, Cookie-Store, working for multiple domains

I have a client React app that consumes data from multiple backends. in development, those backends are - http://localhost:8001, - http://localhost:8002, - http://localhost:8003,...

How can I mount Cloudflare Durable Objects to a route?

Durable Objects Docs: https://hono.dev/examples/cloudflare-durable-objects Durable Object example straight from docs. tldr; it's a class. ```ts import { Hono } from 'hono'...

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