You cannot use different slug names for the same dynamic path Next.js Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

Next.js: Error: You cannot use different slug names for the same dynamic path ('id' !== 'slug')

Sibling dynamic folders at the same level use different parameter names.

Exact message you may see You cannot use different slug names for the same dynamic path ('id' !== 'slug')Error: You cannot use different slug names for the same dynamic pathdifferent slug names for the same dynamic path
Seen on: Next.js

Meaning

At one path level only one dynamic segment name is allowed: [id] and [slug] can't coexist. Rename them to the same name, nest them differently, or merge routes. After renaming restart next dev and clear .next.

Common causes

  • app/posts/[id] and app/posts/[slug] both present
  • Pages and app routes with different names for the same segment
  • Leftover renamed folder
  • Catch-all conflicts
  • Copy-paste folder

⚡ Quick fix

  1. Rename to a single consistent param name
  2. Remove the stale folder
  3. Restart dev server and delete .next

Detailed fix by platform

Linux

  1. rm -rf .next && npm run dev after renaming folders

How to diagnose

  1. Folders — Both [id] and [slug]?
  2. Level — Same parent?
  3. Cache — .next cleared?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

[Vue Router warn]: No match found for location with path — Vue Router: [Vue Router warn]: No match found for location with path "/users/42" (Vue)[Vue Router warn]: No…Conflicting app and page file was found — Next.js: ⨯ Conflicting app and page file was found, please remove the conflicting files to continue: "pages/index.tsx" - "app/page.tsx" (Next.js)Conflicting app and p…CORS error calling Next.js API route / route handler — Browser: Access to fetch at 'https://api.example.com/api/data' from origin 'https://app.example.com' has been blocked by CORS policy (Next.js route handler) (Next.js)CORS error calling Ne…createContext only works in Client Components — Next.js: You're importing a component that needs createContext. It only works in a Client Component but none of its parents are marked with "use client" (Next.js)createContext only wo…next build: fetch failed ECONNREFUSED (build-time API) — Next.js: Error occurred prerendering page "/blog" TypeError: fetch failed { cause: Error: connect ECONNREFUSED 127.0.0.1:3000 } (Next.js)next build: fetch fai…next build: JavaScript heap out of memory — Next.js: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory (during next build) (Next.js)next build: JavaScrip…NextRouter was not mounted — Error: NextRouter was not mounted. (React)NextRouter was not mo…No routes matched — No routes matched location "/x" (React)No routes matchedYou canno…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.