Bug Report: `params.slug` is empty object `{}` in Edge Runtime with catch-all optional routes `[[...slug]]`
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/hungry-solomon-2dd9xw
To Reproduce
- Create a catch-all optional route file:
app/test/[[...slug]]/page.tsx - Set the route to use edge runtime:
export const runtime = "edge" - Type
paramsasPromise<{ slug?: string[] }>(Next.js 15 format) - Await the
paramsPromise:const resolvedParams = await params - Access
resolvedParams.slug- it will beundefined - Inspect
resolvedParams- it will be an empty object{}
Example URL: /test/homepage
Expected: resolvedParams should be { slug: ['homepage'] }
Actual: resolvedParams is {}
Current vs. Expected behavior
Current Behavior
-
paramsis correctly typed asPromise<{ slug?: string[] }> -
await paramsresolves successfully (no error thrown) - The resolved value is an empty object
{}with no properties -
resolvedParams.slugisundefined -
Object.keys(resolvedParams)returns[] - This only occurs in Edge Runtime - works correctly in Node.js runtime
Expected Behavior
-
await paramsshould resolve to{ slug: ['homepage'] }for URL/test/homepage -
resolvedParams.slugshould be['homepage'](array of path segments) - For root route
/test,resolvedParams.slugshould beundefined(optional catch-all)
Provide environment information
- **Next.js version:** `15.5.7`
- **React version:** `19.0.1`
- **Node.js version:** `>=18.18.0`
- **Runtime:** Edge Runtime (`export const runtime = "edge"`)
- **Deployment:** Cloudflare Pages (requires edge runtime)
- **Route Type:** Catch-all optional route `[[...slug]]`
- **App Router:** Yes (using `app/` directory)
Which area(s) are affected? (Select all that apply)
Dynamic Routes
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
Workaround Currently Used
We're using middleware to extract the slug from the URL pathname and pass it via headers:
// middleware.ts
export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
if (pathname.startsWith('/test/')) {
const slug = pathname.replace(/^\/test\/?/, '').replace(/\/$/, '') || 'home';
const requestHeaders = new Headers(request.headers);
requestHeaders.set('x-pathname', pathname);
return NextResponse.next({ request: { headers: requestHeaders } });
}
return NextResponse.next();
}
What behavior do you observe locally though? Not local dev, but local build + start?
@icyJoseph The issues occurs in local build + start as well. When export const runtime = "edge", it fails to get the param
Could you submit a real repository please? Otherwise I am gonna be asking questions here, eventually time box time to try to repro, and likely fail to reproduce the issue.
@icyJoseph https://codesandbox.io/p/sandbox/hungry-solomon-2dd9xw Can you check this
Hi @icyJoseph , any update on this
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!