HonoH
Hono6mo ago
Eternal

`args?` is blank despite using zValidator

Set up details

Using Deno (2.4.2, the latest version)
And all the other packages are also up-to-date (Hono 4.8.5, zod-validator 0.7.1, Zod 4.0.5)

I'm getting the packages from NPM, not JSR

Issue

Hono client infers the route as $post: (args?: {}, options?: ClientRequestOptions). Notice the blank args?. This is not expected behavior

Expected behavior is args: { json: { name: string } }

Server Code:

import { Hono } from 'hono'
import { zValidator as baseZodValidator } from '@hono/zod-validator';
import z from 'zod';

let state = {}
const app = new Hono()
  .post("/set", baseZodValidator("json", z.object({
    name: z.string()
  })), (c) => {
    const partialState = c.req.valid("json")
    state = { ...state, ...partialState }
    return c.json(state)
  })
  .get('/', (c) => {
    return c.json(state)
  })

Deno.serve(app.fetch)
export type AppType = typeof app


Client code

const globalStateClient = hc<AppType>("localhost:8080")
globalStateClient.set.$post()
Was this page helpful?