T
TanStack•2mo ago
foreign-sapphire

How to emulate Next.js app router constraints

Unlike probably most people here, I like next's directory-based routing model and hate remix's file-based routing mode, whether with flat-routes or not Unfortunately I don't like the rest of Next, so I was wondering if there's any way to emulate its routing using tanstack router's router settings. Basically what I want is:
šŸ“ src/routes/
ā”œā”€ā”€ šŸ“„ page.tsx ('/' route file)
ā”œā”€ā”€ šŸ“„ a.tsx (ignored)
ā”œā”€ā”€ šŸ“„ __root.tsx (root route)
ā”œā”€ā”€ šŸ“ blog/
│ ā”œā”€ā”€ šŸ“„ layout.tsx ('/blog/*' route layout)
│ ā”œā”€ā”€ šŸ“„ page.tsx ('/blog/' route file)
│ ā”œā”€ā”€ šŸ“„ b.tsx (ignored)
│ └── šŸ“ $slug/
│ └── šŸ“„ page.tsx ('/blog/$slug' route file)
└── šŸ“ about/
└── šŸ“„ page.tsx ('/about/' route file)
└── šŸ“ components/
└── šŸ“„ c.tsx (ignored)
šŸ“ src/routes/
ā”œā”€ā”€ šŸ“„ page.tsx ('/' route file)
ā”œā”€ā”€ šŸ“„ a.tsx (ignored)
ā”œā”€ā”€ šŸ“„ __root.tsx (root route)
ā”œā”€ā”€ šŸ“ blog/
│ ā”œā”€ā”€ šŸ“„ layout.tsx ('/blog/*' route layout)
│ ā”œā”€ā”€ šŸ“„ page.tsx ('/blog/' route file)
│ ā”œā”€ā”€ šŸ“„ b.tsx (ignored)
│ └── šŸ“ $slug/
│ └── šŸ“„ page.tsx ('/blog/$slug' route file)
└── šŸ“ about/
└── šŸ“„ page.tsx ('/about/' route file)
└── šŸ“ components/
└── šŸ“„ c.tsx (ignored)
I tried this configuration, but it ignores directories with a name that fall into the pattern:
tanstackRouter({
autoCodeSplitting: true,
routeFileIgnorePrefix: '',
routeFileIgnorePattern: '^(?!.*(?:page|layout|__root)\\.tsx$).*$',
routeToken: 'layout',
indexToken: 'page',
})
tanstackRouter({
autoCodeSplitting: true,
routeFileIgnorePrefix: '',
routeFileIgnorePattern: '^(?!.*(?:page|layout|__root)\\.tsx$).*$',
routeToken: 'layout',
indexToken: 'page',
})
1 Reply
deep-jade
deep-jade•2mo ago
i guess this is simply not possible right now can you please create a github issue to track this?

Did you find this page helpful?