vercel/next.js · error · Error
Segment names may not start or end with extra brackets ('${s
Error message
Segment names may not start or end with extra brackets ('${segmentName}'). What it means
After stripping the outer brackets (and optional catch-all brackets) from a dynamic segment, _insert throws if the remaining name still starts with '[' or ends with ']' — e.g. [[foo]] used outside a catch-all or unbalanced brackets — because nested/extra brackets are not a valid parameter name.
Source
Thrown at packages/next/src/shared/lib/router/utils/sorted-routes.ts:110
// Strip optional `[` and `]`, leaving only `something`
segmentName = segmentName.slice(1, -1)
isOptional = true
}
if (segmentName.startsWith('…')) {
throw new Error(
`Detected a three-dot character ('…') at ('${segmentName}'). Did you mean ('...')?`
)
}
if (segmentName.startsWith('...')) {
// Strip `...`, leaving only `something`
segmentName = segmentName.substring(3)
isCatchAll = true
}
if (segmentName.startsWith('[') || segmentName.endsWith(']')) {
throw new Error(
`Segment names may not start or end with extra brackets ('${segmentName}').`
)
}
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) {View on GitHub (pinned to 0eb3775416)
Solutions
- Remove the extra leading/trailing brackets from the segment name.
Defensive patterns
Strategy: validation
When it happens
Trigger: A route segment name starts or ends with extra brackets.
Common situations: Folder names like '[[slug]' or '[slug]]' with mismatched brackets.
AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19).
Data as JSON: /api/errors/c62a37bbcf67455d.
Report an issue: GitHub.