vercel/next.js · error · Error
You cannot use different slug names for the same dynamic pat
Error message
You cannot use different slug names for the same dynamic path ('${previousSlug}' !== '${nextSlug}'). What it means
handleSlug throws when a dynamic segment level already has a slug name and another route at the same level uses a different one (e.g. pages/[post]/x and pages/[id]/x). Only one dynamic parameter name is allowed per level because the router stores a single param value for that position.
Source
Thrown at packages/next/src/shared/lib/router/utils/sorted-routes.ts:130
)
}
if (segmentName.startsWith('.')) {
throw new Error(
`Segment names may not start with erroneous periods ('${segmentName}').`
)
}
function handleSlug(previousSlug: string | null, nextSlug: string) {
if (previousSlug !== null) {
// If the specific segment already has a slug but the slug is not `something`
// This prevents collisions like:
// pages/[post]/index.js
// pages/[id]/index.js
// Because currently multiple dynamic params on the same segment level are not supported
if (previousSlug !== nextSlug) {
// TODO: This error seems to be confusing for users, needs an error link, the description can be based on above comment.
throw new Error(
`You cannot use different slug names for the same dynamic path ('${previousSlug}' !== '${nextSlug}').`
)
}
}
slugNames.forEach((slug) => {
if (slug === nextSlug) {
throw new Error(
`You cannot have the same slug name "${nextSlug}" repeat within a single dynamic path`
)
}
if (slug.replace(/\W/g, '') === nextSegment.replace(/\W/g, '')) {
throw new Error(
`You cannot have the slug names "${slug}" and "${nextSlug}" differ only by non-word symbols within a single dynamic path`
)
}
})View on GitHub (pinned to 0eb3775416)
Solutions
- Use the same slug name for the same dynamic path across routes.
Defensive patterns
Strategy: validation
When it happens
Trigger: Two routes use different slug names for the same dynamic path.
Common situations: /blog/[id] and /blog/[postId] both exist; the slug names must match.
AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19).
Data as JSON: /api/errors/6f8257b1278b4b8f.
Report an issue: GitHub.