Skip to content

fix(vercel): add void return type and ctx param for Next.js 15 App Router compatibility#4878

Draft
AliiiBenn wants to merge 1 commit intohonojs:mainfrom
AliiiBenn:fix/nextjs15-types
Draft

fix(vercel): add void return type and ctx param for Next.js 15 App Router compatibility#4878
AliiiBenn wants to merge 1 commit intohonojs:mainfrom
AliiiBenn:fix/nextjs15-types

Conversation

@AliiiBenn
Copy link
Copy Markdown

@AliiiBenn AliiiBenn commented Apr 13, 2026

Summary

The handle() function in hono/vercel adapter was incompatible with Next.js 15 App Router route handler types.

Two type errors were reported:

  1. Return type was Response | Promise<Response> but Next.js 15 expects Response | void | Promise<Response | void>
  2. Handler was missing the optional ctx parameter that Next.js 15 passes

Fix

  • Added void to the return type union
  • Added optional ctx?: unknown parameter to match Next.js 15 expectations

The runtime behavior is unchanged since app.fetch(req) always returns a Response (via notFoundHandler if needed).

Test plan

  • Verify tsc --noEmit passes in a Next.js 15 App Router project using the documented setup

…uter compatibility

The handle() function now returns a function with a void return type
and accepts an optional ctx parameter, which are required by Next.js 15
App Router route handler types.

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
@AliiiBenn AliiiBenn marked this pull request as draft April 13, 2026 14:09
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.89%. Comparing base (1aa32fb) to head (e237eb6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4878   +/-   ##
=======================================
  Coverage   92.89%   92.89%           
=======================================
  Files         177      177           
  Lines       11797    11799    +2     
  Branches     3515     3514    -1     
=======================================
+ Hits        10959    10961    +2     
  Misses        837      837           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant