Next.js Discord

Discord Forum

Add `test` prefix to all routes in particular group (route interception, optional dynamic routes)

Unanswered
Wendell Misiedjan posted this in #help-forum
Open in Discord
We've an dashboard under the /admin/.... path, we want to implement a url based testMode toggle / state by prefixing /admin/test/.... to all paths but within the same 'group' in Next.js, whats the best way to achieve this? This should work similar as the Stripe test mode toggle, any tips?

Example:
/admin/test/tickets - only shows test tickets
/admin/tickets - real tickets

2 Replies

Instead of modifying the segment configuration, could you just accept a param to put it into test mode? /admin/tickets?mode=test
That would be much easier to manage in the longrun imo