honojs/hono

Next.js 15: `Type "FetchEventLike" is not a valid type for the function's second argument.`

Closed this issue · 2 comments

What version of Hono are you using?

4.6.5

What runtime/platform is your app running on?

Node/Vercel

What steps can reproduce the bug?

Screenshot 2024-10-22 at 2 09 38 PM

☝️ The above error occurs when upgrading to Next.js 15. This, of course, uses hono/vercel's handler with the Route Handler convention. Example:

import { api } from '@repo/api/hono';

import { handle } from 'hono/vercel';

export const DELETE = handle(api);
export const GET = handle(api);
export const POST = handle(api);
export const OPTIONS = handle(api);

Like the error indicates, it has to do with the FetchEventLike type from Hono:

export const handle =
(app: Hono<any, any, any>) =>
(req: Request, requestContext: FetchEventLike): Response | Promise<Response> => {
return app.fetch(req, {}, requestContext as any)
}

I don't know if simply removing the requestContext argument along with its type is sufficient, but when I remove it locally and try to build all seems to work just fine. I don't see anything in the Route Handlers documentation that says it can't be removed, but I defer to the maintainers.

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

I'm using this in a monorepo context, for clarity, but I don't think that's relevant for this specific error.

Hi @devjmetivier

This is a bug. I'll fix it.

@yusukebe Could you please release a new version soon? 🙏🏻