nextjs - 💡(How to fix) Fix Bug Report: `params.slug` is empty object `{}` in Edge Runtime with catch-all optional routes `[[...slug]]` [5 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#87068Fetched 2026-04-08 02:07:52
View on GitHub
Comments
5
Participants
3
Timeline
13
Reactions
0
Timeline (top)
commented ×5mentioned ×3subscribed ×3issue_type_added ×1

Error Message

  • await params resolves successfully (no error thrown)

Fix Action

Fix / Workaround

Workaround Currently Used

We're using middleware to extract the slug from the URL pathname and pass it via headers:

Code Example

- **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)

---

// 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();
}
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/hungry-solomon-2dd9xw

To Reproduce

  1. Create a catch-all optional route file: app/test/[[...slug]]/page.tsx
  2. Set the route to use edge runtime: export const runtime = "edge"
  3. Type params as Promise<{ slug?: string[] }> (Next.js 15 format)
  4. Await the params Promise: const resolvedParams = await params
  5. Access resolvedParams.slug - it will be undefined
  6. 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

  • params is correctly typed as Promise<{ slug?: string[] }>
  • await params resolves successfully (no error thrown)
  • The resolved value is an empty object {} with no properties
  • resolvedParams.slug is undefined
  • Object.keys(resolvedParams) returns []
  • This only occurs in Edge Runtime - works correctly in Node.js runtime

Expected Behavior

  • await params should resolve to { slug: ['homepage'] } for URL /test/homepage
  • resolvedParams.slug should be ['homepage'] (array of path segments)
  • For root route /test, resolvedParams.slug should be undefined (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 (local)

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();
}

extent analysis

TL;DR

  • The issue can be worked around by using a middleware function to extract the slug from the URL pathname and pass it via headers, as currently implemented.

Guidance

  • Verify that the middleware.ts function is correctly setting the x-pathname header and that this header is accessible in the page.tsx file.
  • Check if the params Promise is being awaited correctly and that the resolvedParams object is being accessed after the await expression.
  • Consider logging the request.nextUrl.pathname value in the middleware.ts file to ensure it matches the expected URL structure.
  • If the issue persists, try logging the resolvedParams object in the page.tsx file to see if it contains any unexpected properties or values.

Example

// page.tsx
console.log('resolvedParams:', resolvedParams);
console.log('request headers:', request.headers);

Notes

  • The issue seems to be specific to the Edge Runtime and does not occur in the Node.js runtime.
  • The current workaround using middleware may be sufficient, but it would be ideal to understand why the params Promise is resolving to an empty object in the Edge Runtime.

Recommendation

  • Apply workaround: The current middleware-based workaround seems to be effective, and applying it as a permanent solution may be the most straightforward way to resolve the issue, given the constraints of the Edge Runtime.

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

nextjs - 💡(How to fix) Fix Bug Report: `params.slug` is empty object `{}` in Edge Runtime with catch-all optional routes `[[...slug]]` [5 comments, 3 participants]