5

How can I implement Next js feature Catch all routes [[...slug.tsx]] (https://nextjs.org/docs/routing/dynamic-routes#optional-catch-all-routes) without deleting the index.js page? If I don't delete it, I get this error:

Error: You cannot define a route with the same specificity as a optional catch-all route ("/" and "/[[...slug]]").

I read a recommendation changing to non-optional catch all routes ([...slug.tsx]) .. but that doesn't allow me to catch a route without a slug (i.e /post)

  • 2
    If you also want to catch the route without the slug in your catch-all route, why do you need the `index.js` page? – juliomalves Feb 16 '21 at 21:16

0 Answers0