T
TanStack16mo ago
fascinating-indigo

Lazy file route use cases

When should I create a lazy file route as opposed to a regular non-lazy route? All of the examples in the documentation use non-lazy file routes. I was wondering when I would need to use lazy file routes...
4 Replies
eastern-cyan
eastern-cyan16mo ago
When you don’t want the user to download the whole JS code at the beginning and only when they go to that specific page
fascinating-indigo
fascinating-indigoOP15mo ago
Ok that makes sense. Thank you!
rare-sapphire
rare-sapphire15mo ago
And what examples would apply here? if I have an index route posts, would each individual posts/$ route make sense to be lazy loaded when the user wants to see an individual post? Would static routes make sense?
dependent-tan
dependent-tan15mo ago
One use case might be if your site also includes an admin area to manage posts. Most people visiting the site will never visit that page, so it makes sense to lazy-load the admin code.

Did you find this page helpful?