vercel/next.js · error · Error
You cannot have the slug names "${slug}" and "${nextSlug}" d
Error message
You cannot have the slug names "${slug}" and "${nextSlug}" differ only by non-word symbols within a single dynamic path What it means
handleSlug throws when two slug names at the same level become identical once non-word characters (\W) are stripped, e.g. [my-post] vs [my_post]. Because params are keyed by normalized names, such names would collide at runtime.
Source
Thrown at packages/next/src/shared/lib/router/utils/sorted-routes.ts:144
// 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`
)
}
})
slugNames.push(nextSlug)
}
if (isCatchAll) {
if (isOptional) {
if (this.restSlugName != null) {
throw new Error(
`You cannot use both an required and optional catch-all route at the same level ("[...${this.restSlugName}]" and "${urlPaths[0]}" ).`
)
}
handleSlug(this.optionalRestSlugName, segmentName)
// slugName is kept as it can only be one particular slugNameView on GitHub (pinned to 0eb3775416)
Solutions
- Use slug names that differ by more than non-word symbols within one dynamic path.
Defensive patterns
Strategy: validation
When it happens
Trigger: Two slug names differ only by non-word symbols.
Common situations: Slugs like 'post-id' and 'post_id' used in the same dynamic path.
AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19).
Data as JSON: /api/errors/761d0fc58879ade5.
Report an issue: GitHub.