T
TanStack8mo ago
rare-sapphire

Where are beforeLoad and loader executed?

Does loader always run in the server, and beforeLoad always run in client and can access to client-side api? Where can I find the environments the functions are executed in? I’m coming from Next.js so I’m a little confused when it’s not explicitly written in
2 Replies
stormy-gold
stormy-gold8mo ago
it depends. are you using start? during SSR , beforeload and loader run on the server. upon subsequent navigations both run on the client
rare-sapphire
rare-sapphireOP8mo ago
No, I’m just using Tanstack Router Does Subsequent navigations mean when navigated to other routes via <Link /> or something like that? Then is it common practice to use Server Functions inside loader to make sure the some piece of code always run on the server?

Did you find this page helpful?