T
TanStack3y ago
continuing-cyan

Using Router in multiple projects within a monorepo

Got a question about using Router in a monorepo. This question is purely out of curiosity, not a problem I'm facing. My question is entirely from the development aspect because I'm assuming you are passing callbacks or not trying to create router-reliant internal packages. From what I understand, your existing build processes should work fine since you'd be building/compiling the individual application within its own directory. But from the development standpoint, what happens when you've opened the monorepo at the root and go into a specific project/app within it? Does your TS inferrence still work? because Router relies you being able to declare the type of the router on the Register interface.
2 Replies
wise-white
wise-white3y ago
I have nx monorepo with multiple libs I separated router into its own library with router.d.ts file which I import in routes.ts where I build all routes I thought that I would just connect this router.d.ts file inside libs where I need types for router through tsconfig.json. It didn’t work. It seems to work in VS Code across multiple libs without issue It doesn’t work in WebStorm though Generally an example with monorepo setup would be good Like for example two apps with separate routers and libs importing types for router it needs
continuing-cyan
continuing-cyanOP3y ago
Thank you!

Did you find this page helpful?