#Top level catch-all route alongside a dynamic route? Using Next14 with app router

2 messages · Page 1 of 1 (latest)

open surge
#

What is the correct way to have a top level catch-all route (i.e. /app/[...slugs]/page.tsx) alongside a dynamic route (i.e. /app/[slug]/page.tsx)? I've managed to get it working by trying to retrieve the 'slug' from our CMS in the dynamic route (/app/[slug]), if that is not found we then call the Page export from the catch-all route passing in params something like: <Page params={{ slugs: [params.slug] }} /> . This works but feels a bit wrong, especially in my use case I have this at 3 levels so the catch-all (/app/[...slugs]) also tries to fetch data from the CMS if it is not found it then passes this onto another route (in my case /app/product/[slug]).

I've asked this same question in the NextJS subreddit with some more detail: https://www.reddit.com/r/nextjs/comments/1dj4kzt/

Reddit

Explore this post and more from the nextjs community

hidden owlBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)