Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

how dynamically add multiple tanstack-router apps into one container? #4110

Unanswered
FoHoOV asked this question in Q&A
Discussion options

In our monorepo we have:

apps/
├── app1
├── app2
└── app3

Each of these is a TanStack Router app using file-based routing. We could build app1, app2 and app3 separately, host them as three different processes, and use a complex network (or Kubernetes) config to route them under one origin:

/app1 → app1
/app2 → app2
/app3 → app3

I’d like to replace that with a single “container” app that dynamically loads and mounts all three, but still preserves auto-code-splitting. My current approach is:

const router = createTanstackRouter({
  routeTree: routeTree.addChildren([
    // keep any file-based children in the container
    ...(routeTree.children! as unknown as AnyRoute["children"]),
    // mount each micro-app under its own path
    ...mount(app1Routes),
    ...mount(app2Routes),
    ...mount(app3Routes),
  ]),
});

This lets us build only the container—but unfortunately it bundles everything into one huge file and loses the automatic splitting. Are there any recommended approaches this?

You must be logged in to vote

Replies: 2 comments

Comment options

If there are no solutions to this we could have externalRoutes in tsr config that could take an array of other routes directories to include in its generator:

{
    // others
    externalRoutes: ["../app1/routes", "../app2/routes"]
}
You must be logged in to vote
0 replies
Comment options

I'm also experiencing the same problem.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.