#Optional route
1 messages · Page 1 of 1 (latest)
Hi @neon falcon. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the information provided in the extracts, it seems like you're trying to use optional route parameters in Next.js, but you're encountering an error because optional route parameters are not yet fully supported in Next.js.
In Next.js, optional catch-all routes can be created by including the parameter in double brackets (**[...slug]]). For example, pages/shop/[[...slug]].js will match /shop, in addition to /shop/clothes, /shop/clothes/tops, /shop/clothes/tops/t-shirts ([source** (https://nextjs.org/docs/pages/building-your-application/routing/dynamic-routes#optional-catch-all-segments)).
However, it's important to note that there's a difference between optional catch-all routes and optional route parameters. The former is supported in Next.js, but the latter is not yet supported, as indicated by the error message you're seeing.
If you're trying to use optional route parameters (not optional catch-all routes), you might encounter issues. There's an open issue on GitHub where a user reported a similar error when trying to use optional route parameters (source (https://github.com/vercel/next.js/issues/53112)).