Next.js Discord

Discord Forum

Catch all route at root of app

Answered
Himalayan posted this in #help-forum
Open in Discord
HimalayanOP
Can I have a catch all route page at the root of the app rather than a page?
Option 1
/app
----/[...slug]
    ----page.tsx

Or option 2
/app
----[...page].tsx

Rather than
/app
----page.tsx


Neither option 1 or option 2 seem to work
Even if just defining a page like
const Page = () => {
  return <div>page</div>
}

export default Page


Visiting / will just 404. Unless I use page.tsx
Answered by joulev
option 1 is the way. but [...slug] matches everything except /. to also match / you need [[...slug]]

app/
  [[...slug]]/
    page.tsx
View full answer

1 Reply