Using global variable store in @tanstack/start dangerous? or just acceptable in @tanstack/router?
I'm looking at the tanstack/router examples for data loading, and I will see this pattern
Or
I understand that @tanstack/router it is 100% on the client, so this should be fine. But can I use this pattern in @tanstack/start as well? Since it will be run on the server, will these global variables LEAK if they are run for different authenticated users for example? Or is tanstacks/start implementation that these are run inside some closure?
In @tanstack/start
2 Replies
national-goldOP•7mo ago
The queryClient is inside a closure and is only passed via the router context. But is this pattern dangerous in tanstack/start?
sensitive-blue•7mo ago
you should not use global vars with start
make sure to create whatever you need inside of the e.g. createRouter() function, as this will be called per request