Hono

H

Hono

This is the official Hono discord server for the community

Join

How to make c.get("jwtPayload") type safe

I'm using jwtAuth and I want to add type to the jwtPayload

Unable to get RPC working with the inferred input type

Server is a simple example from the docs, using Bun. The client is a simple component in Vue. Path-type and return type seems to work correctly, but the input type does not. I would assume type safety should complain if I send it something other than what I give to zValidator? Also, it does not help me auto-complete the query.name...
No description

Nested islands in HonoX

I'm trying to nest islands in fashion similar to this: ``` // islands/toggleSection.tsx export const ToggleSection = (children, isOpen, onToggle) => {...

how to use mongodb with cloudfare hono

Hey guys can anyone help me integrating my mongodb with hono cloudfare.

zValidator Middleware Error

I have literally only implemented the example ```import { zValidator } from "@hono/zod-validator"; import { Hono } from "hono"; import { z } from "zod";...

JSX.Element

Namespace ... JSX has no exported member 'Element'. I have a simple type like this ``` export type PageProps = {...

How to upload a file and track it's progress on the client-side?

I send a file with the following function: ``` const uploadFile = async (thatFile) => { // Use a custom TransformStream to track upload progress...

Cookies not available in other Route

``ts r.get("/login/:userId", async (c): Promise<Response> => { const redirectUri = ${c.env.WORKER_BASE_URL}/callback`; setCookie(c, "userId", c.req.param("userId"), {...

Uploading a file using FormData from React Native to Hono

using Hono 4.4.13 What runtime/platform is your app running on? NodeJs ...
No description

Sentry - hono/trpc/cloudflare workers

Hi guys, I'm trying to implement sentry into my hono/trpc/cloudflare application. If I'm just using the @hono/sentry middleware, what errors are exactly being caught? Will this middleware automatically catch all expcetions thrown from my middleware trpc server? I guess if I want to have a bit more fine grained control (as to when I'm capturing exceptions) inside of each of my trpc procedures, I need a bit of a different implementation, right? I'm not quite sure if I understood how everything works, I would very much appreciate any feedback!...

Custom response with bearerAuth

I would like to return a custom response when verifyToken is false. ``` const authMiddleware = bearerAuth({ verifyToken: async (token, c) => { const data = await c.env.AUTH.get(token);...

Enforce OpenAPI types

Hey there, I'm currently working on a openapi-router package, which aims to enforce types (generated from an OpenAPI document using openapi-typescript) in the routers of web frameworks like Hono or ExpressJs. I've successfully added support for ExpressJs, as its typings are relatively straightforward. However, I'm finding the Hono types more complex, and I could use some assistance in creating the appropriate Hono types for the openapi-router package. ...

zValidator not coercing types correctly

"@hono/zod-validator": "0.2.2",
"hono": "4.4.10",
"@hono/zod-validator": "0.2.2",
"hono": "4.4.10",
...
No description

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:...
Next