TanStackT
TanStack9mo ago
13 replies
clean-aquamarine

Automatic Code Splitting

Hello, i would like to know if automatic code splitting works only with files named route.tsx or it's available for all routable file in our routes directory.
Encapsulating a route's files into a directory
Since TanStack Router's file-based routing system is designed to support both flat and nested file structures, it's possible to encapsulate a route's files into a single directory without any additional configuration.

To encapsulate a route's files into a directory, move the route file itself into a .route file within a directory with the same name as the route file.

For example, if you have a route file named posts.tsx, you would create a new directory named posts and move the posts.tsx file into that directory, renaming it to route.tsx.

Before

posts.tsx
After

posts
route.tsx

this part confused me a little on the doc. I would like to know if posts/$postId.tsx benefit automatic code spliting.
Thanks a lot !
Was this page helpful?