Next.js Discord

Discord Forum

Swapping Multiple Applications in Next.js with App Router Based on Environment

Unanswered
New Guinea Freshwater Crocodile posted this in #help-forum
Open in Discord
New Guinea Freshwater CrocodileOP
I'm working with the Next.js App Router and I want to build a setup that allows me to swap between multiple applications using the same route structure (e.g., /dashboard, /login, etc.). My goal is to switch between these apps via environment variables, and ideally:

Only the enabled app gets bundled at build time.

The disabled apps are completely excluded from the final bundle (not just hidden or conditionally rendered).

Has anyone implemented something like this?

2 Replies

New Guinea Freshwater CrocodileOP
It feels easy to achieve but in fact its not. So I cant have like app/store1 app/store2 and conditionally enable only one. Ill try to create another folder like storefronts/store1, /store2 and then symlink maybe
New Guinea Freshwater CrocodileOP
no actually this completely unsupported currently.