nextjs - 💡(How to fix) Fix Type error: Dynamic API route handler params type mismatch in Next.js App Router [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#83821Fetched 2026-04-08 02:21:22
View on GitHub
Comments
3
Participants
3
Timeline
8
Reactions
0
Author
Assignees
Timeline (top)
commented ×3assigned ×1issue_type_added ×1labeled ×1

Error Message

  1. Observe the type error about the dynamic API route handler params Actual: The build fails with a type error about the params type, expecting Promise<{ id: string }> instead of { id: string }.
  • The error occurs in a fresh Next.js app with the minimal reproduction. error =>{ Type error: Type 'typeof import("/Users/lucaseduardo/bug-repo/app/api/route/[id]/route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/route/[id]">'.

Code Example

Operating System:
  Platform: darwin (macOS)
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0

Binaries:
  Node: v23.2.0
  npm: 10.x (exact version not available due to PATH issue)

Relevant Packages:
  next: 15.5.2
  react: 19.x
  react-dom: 19.x
  typescript: 5.9.2

Next.js Config:
  output: N/A

Which area(s) are affected?
- App Router
- API Routes

Which stage(s) are affected?
- Build
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/LucasEdwa/bug-repo

To Reproduce

  1. Clone the reproduction repo: git clone https://github.com/LucasEdwa/bug-repo.git
  2. Run npm install
  3. Run npm run build
  4. Observe the type error about the dynamic API route handler params

Current vs. Expected behavior

Expected: The build should succeed with the documented dynamic API route handler signature. Actual: The build fails with a type error about the params type, expecting Promise<{ id: string }> instead of { id: string }.

Provide environment information

Operating System:
  Platform: darwin (macOS)
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0

Binaries:
  Node: v23.2.0
  npm: 10.x (exact version not available due to PATH issue)

Relevant Packages:
  next: 15.5.2
  react: 19.x
  react-dom: 19.x
  typescript: 5.9.2

Next.js Config:
  output: N/A

Which area(s) are affected?
- App Router
- API Routes

Which stage(s) are affected?
- Build

Which area(s) are affected? (Select all that apply)

Route Handlers

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

  • This issue occurs locally on macOS (Apple Silicon, Node v23.2.0).
  • I am not deploying to Vercel or Docker; this is a local development build.
  • The error occurs in a fresh Next.js app with the minimal reproduction.
  • I have tried both stable and canary versions of Next.js and TypeScript.
  • The issue is not browser-specific, as it happens at build time.
  • No experimental or advanced Next.js features are enabled.

error =>{ npm run build

[email protected] build next build --turbopack

▲ Next.js 15.5.3 (Turbopack)

Creating an optimized production build ... ✓ Finished writing to disk in 38ms ✓ Compiled successfully in 1605ms Linting and checking validity of types .Failed to compile.

Type error: Type 'typeof import("/Users/lucaseduardo/bug-repo/app/api/route/[id]/route")' does not satisfy the constraint 'RouteHandlerConfig<"/api/route/[id]">'. Types of property 'POST' are incompatible. Type '(request: NextRequest, { params }: { params: { id: string; }; }) => Promise<NextResponse<{ id: string; }>>' is not assignable to type '(request: NextRequest, context: { params: Promise<{ id: string; }>; }) => void | Response | Promise<void | Response>'. Types of parameters '__1' and 'context' are incompatible. Type '{ params: Promise<{ id: string; }>; }' is not assignable to type '{ params: { id: string; }; }'. Types of property 'params' are incompatible. Property 'id' is missing in type 'Promise<{ id: string; }>' but required in type '{ id: string; }'.

Next.js build worker exited with code: 1 and signal: null

extent analysis

TL;DR

  • The issue can be resolved by updating the type definition for the API route handler to match the expected RouteHandlerConfig type, specifically changing the params type to Promise<{ id: string }>.

Guidance

  • Review the type definitions for the API route handler in app/api/route/[id]/route to ensure they align with the RouteHandlerConfig type.
  • Update the params type in the API route handler to Promise<{ id: string }>, as indicated by the error message.
  • Verify that the next and typescript versions are compatible and consider updating to the latest versions if necessary.
  • Check the Next.js documentation for any changes to the RouteHandlerConfig type or API route handling in version 15.5.2.

Example

// app/api/route/[id]/route.ts
import type { NextRequest, NextResponse } from 'next';

export const POST = async (request: NextRequest, { params }: { params: Promise<{ id: string }> }) => {
  const { id } = await params;
  // Handle the request
  return NextResponse.json({ id });
};

Notes

  • The issue seems to be related to a type mismatch between the expected and actual types of the params property in the API route handler.
  • The provided error message and stacktrace suggest that the issue is specific to the next build command and the RouteHandlerConfig type.

Recommendation

  • Apply workaround: Update the type definition for the API route handler to match the expected RouteHandlerConfig type, as described in the guidance section. This should resolve the type error and allow the build to succeed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING