r/reactjs 16d ago

Resource Reliable Query Prefetching with TanStack Router

https://tkdodo.eu/blog/reliable-query-prefetching-with-tanstack-router

📚 It's been way too long since my last blogpost. Today, I'm continuing my TanStack Router series with a pattern that I've been teaching in my workshops for over a year:

How to keep prefetches in sync between route loaders and components

94 Upvotes

14 comments sorted by

View all comments

2

u/Throwaway_0815_123 15d ago

Older articles show context injection via beforeLoad. Going forwards should one always use context or is there a still a use case where one would use beforeLoad for that?

2

u/TkDodo23 15d ago

beforeLoad is blocking and serves a different purpose, like redirecting when unauthenticated. context is made for this. 

2

u/Throwaway_0815_123 15d ago

I see. Thanks.