Next.js Discord

Discord Forum

route groups with dynamic routes, is it possible

Unanswered
Ocicat posted this in #help-forum
Open in Discord
OcicatOP
when I have the structure
my-folder
  ├── layout.tsx
  ├── page.tsx
  ├── [slug]
  └── some-route

Nextjs routes to the some-route folder/route instead of the dynamic slug folder/route for the url /some-route. I am assuming Nextjs does this this is because of an exact match.

However, if I were to do the following using https://nextjs.org/docs/app/building-your-application/routing/route-groups:
(my-folder)
  ├── layout.tsx
  ├── page.tsx
  └── [slug]

(my-other-folder)
  ├── layout.tsx
  ├── page.tsx
  └── some-route

I instead always get routed to the [slug] for the url /some-route despite them still being at the same "level" but this time in different groups.

It does route me to some-route with the following configuration as it is almost identical to the first, but then I won't get the layout specified in the my-other-folder group:
(my-folder)
  ├── layout.tsx
  ├── page.tsx
  ├── [slug]
  └── some-route

(my-other-folder)
  ├── layout.tsx
  └── page.tsx


Is this a bug? Is there a way to fix this? Thanks!

0 Replies