T
TanStack2y ago
deep-jade

Why is persistence not instantly restored?

I'm building a local-first app, so I'm using the <PersistQueryClientProvider />, with createSyncStoragePersister(). As it is sync, I expected data to be restored from localStorage instantly, but instead I'm still dealing with a flash of loading states on each reload. How do I avoid this?
1 Reply
genetic-orange
genetic-orange2y ago
What works for me is: await persister.restoreClient(). In tanstack router i throw that in the before load, and there’s no noticeable latency (not scientific). It may be an internal api tho, so may not be recommended to do this

Did you find this page helpful?