Structuring an app with near identical subtrees
Unanswered
Large garden bumble bee posted this in #help-forum
Large garden bumble beeOP
I have an app which will use chatgpt, and implements agents. A user can make any number of agents, but will start with a "default" agent that they can view, which will be mounted under
Here's the catch:
Ideally, I don't really want to extract out every component and then instance them there -- I'd really prefer just to handle this single subtree as a special case. I was considering doing some sort of rewrite, like if they put
I need the route
/my-agent../(chat)/
├── (agents)/
│ ├── agents/
│ │ ├── [agentId]/
│ │ │ ├── [chatId]/
│ │ │ │ └── page.tsx
│ │ │ ├── sources/
│ │ │ │ └── page.tsx
│ │ │ └── page.tsx
│ │ └── page.tsx
│ └── my-agent/
│ ├── [chatId]/
│ │ └── page.tsx
│ ├── sources/
│ │ └── page.tsx
│ └── page.tsxHere's the catch:
agents/:id with the id being the user's default agent will be identical to /my-agent, down the entire subtree. /my-agent ideally would just find the user's agent and then pass that alongIdeally, I don't really want to extract out every component and then instance them there -- I'd really prefer just to handle this single subtree as a special case. I was considering doing some sort of rewrite, like if they put
/agent/:id and the id is their default agent, it will rewrite the route to /my-agent or something. Though, this doesn't seem to work with visiting /my-agent directly https://nextjs.org/docs/app/api-reference/next-config-js/rewritesI need the route
my-agent to exist