Multiple root routers with file based routing
Hi, I would like to know if it was possible, using the file based router mode, to create within the same project multiple root “routers”.
Specifically my use case is that I am creating a browser extension using Plasmo, and so it is as if I have to create multiple separate applications (popup, content, etc.) within a single project containing a single package.json .
2 Replies
metropolitan-bronze•17mo ago
Not in a single project. Since the way type-declaration is done, is via module declaration. Since TS-wouldn't be able to tell which instance of the router is the correct one, that'd make TS essentially useless.
Not sure how extensions are developed, but I'm assuming bundle size is a matter to be considered? If so, having essentially multiple apps under a single package would bloat the bundle size.
You could have your
__root.tsx
just render a <Outlet>
, and divide your apps by their URL.
Like:
Its not perfect, but it'd do the job.
But if bundle size is a concern then a monorepo style setup or just having multiple projects really is your best bet (regardless of the Router you choose).exotic-emeraldOP•17mo ago
will try this way, thank you for the advice😊