T
TanStack2y ago
genetic-orange

createLazyFileRoute with loader

This is probably obvious but it isn't clicking for me — why can't I create a lazy file route but also set a loader or beforeLoad function?
3 Replies
plain-purple
plain-purple2y ago
Code Splitting | TanStack Router Docs
Code splitting and lazy loading is a powerful technique for improving the bundle size and load performance of an application. Reduces the amount of code that needs to be loaded on initial page load
plain-purple
plain-purple2y ago
so you need two files foo.lazy.tsx and foo.tsx foo.tsx contains createFileRoute and the loader
genetic-orange
genetic-orangeOP2y ago
Thank you! Makes complete sense, lazily loading the loader function would defeat the purpose of having a loader function in the first place.

Did you find this page helpful?