#Optional route

1 messages · Page 1 of 1 (latest)

neon falcon
#

Failed to reload dynamic routes: Error: Optional route parameters are not yet supported ("[[slug]]").

hard patioBOT
#

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)).

As a workaround, you might want to consider using optional catch-all routes if it fits your use case. If not, you might need to wait for further updates from the Next.js team regarding the support for optional route parameters.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: