Skip to content

Commit b92b62f

Browse files
committed
fix: update route parameter type to support Promise for Next.js 15 compatibility
1 parent 4a0d75c commit b92b62f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/api/src/next/route.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ export class NextRoute<
127127
protected createRequest(initialConfig: { method: string; url: string }) {
128128
return async (
129129
req: NextRequest,
130-
route: { params: Record<string, string | string[]> },
130+
route: {
131+
params:
132+
| Record<string, string | string[]>
133+
| Promise<Record<string, string | string[]>>;
134+
},
131135
) => {
132136
const { method: _method, url: _url, ...initial } = initialConfig;
133137
const url = req.url;
@@ -155,7 +159,11 @@ export class NextRoute<
155159
...initial,
156160
input,
157161
parsedInput: undefined,
158-
pathParams: route?.params,
162+
pathParams:
163+
// in nextjs 15, route.params is a promise
164+
typeof route?.params?.then === 'function'
165+
? await route.params
166+
: route?.params,
159167
rawRequest: req,
160168
method,
161169
url,

0 commit comments

Comments
 (0)