T
TanStack6mo ago
absent-sapphire

TanStack Start with code-based routing

Hi guys, do you know if it is possible to configure TanStack Start with a code based routing? I am porting my static app, configured with the code based TanStack Router to Start, but I don't seem to succeed. Is it possible at all? Is there any example showing how to do it? Thanks in advance.
5 Replies
flat-fuchsia
flat-fuchsia6mo ago
not possible atm not sure if it ever will be we generate a route manifest based on file routes right now so this at least would have to be generated/created as well
absent-sapphire
absent-sapphireOP6mo ago
Thanks Manuel, I suspected it. I will convert it to a file based routing, though I liked a lot the code based version :/
ambitious-aqua
ambitious-aqua4mo ago
@Manuel Schiller Hey 👋 Just wanted to follow up on this thread. I'm currently building a multitenant visual web editor (kind of like a CMS + Framer hybrid) and I'm exploring TanStack Start as the frontend runtime. The idea is to use a single TanStack Start instance to serve multiple tenant sites — and generate pages/routes dynamically based on CMS data per tenant. However, I’ve hit a major blocker: TanStack Start seems to require file-based routing, while I absolutely need code-based routing so I can generate route trees on the fly (e.g. from API or DB). In development mode, everything works perfectly, but during the build process, I get the error shown in the image. Has anything changed recently? Is there a workaround or plan to support code-based routing officially? Even if I provide a fake __routeTree.gen.ts, the routes-manifest is still missing. So I’m wondering — has this scenario been considered? And what are the options for having a single TanStack codebase serve multiple tenants? If not, I’m considering: - Dropping down to Vinxi + TanStack Router manually Would love to hear if someone has done this before or if there's any roadmap direction here 🙏 Thanks in advance!
No description
No description
flat-fuchsia
flat-fuchsia4mo ago
we dont have a plan to support code based routing right now it might be something that could potentially come later but not before start is stable however, why would you need "generate pages/routes dynamically based on CMS data" ? can you just use a splat route for that?
ambitious-aqua
ambitious-aqua4mo ago
Hey Manuel, thanks for the reply! Totally understand that code-based routing isn’t on the table right now and that stability takes priority. Just to clarify my use case: my goal was to match my CMS data one-to-one with the routing tree — so I could take full advantage of what TanStack routes provide for every CMS-defined page, rather than building internal routing logic around one splat route. Since that's not currently possible, I ended up using a catch-all (/$) route and manually resolving everything inside it based on CMS structure. It works for now and gives me the flexibility I need, though it’s definitely a bit more work. Appreciate the great work on TanStack Start 🙌

Did you find this page helpful?