-
Taking a quick look at https://github.com/trpc/trpc/blob/4932414d3282a1f26787b5f25e9cfef03127d2a5/packages/next/src/withTRPC.tsx is this supported by another means? I mainly want caching in localstorage for fast cold start in a PWA. My other option seems like cache headers but I haven't figured out how to handle that when all requests are based on user session |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You won't be able to use that with the |
Beta Was this translation helpful? Give feedback.
-
Just as an FYI for anyone. If you're getting Date errors from the deserialized/cached result you will probably want to add in this line for superjson parsing 🚀 +++ b/web/utils/usePersistQueryClient.ts
import {
persistQueryClient,
type PersistQueryClientOptions,
} from '@tanstack/react-query-persist-client';
+import superjson from 'superjson';
/**
* A custom hook that replicates the behvaior of PersistQueryClientProvider
export const usePersistQueryClient = ({
...refs.current.persistOptions,
persister: createSyncStoragePersister({
key: 'ls_Sharehouse',
+ serialize: (p) => superjson.stringify(p),
+ deserialize: (s) => superjson.parse(s),
storage:
typeof window !== 'undefined'
? window.localStorage |
Beta Was this translation helpful? Give feedback.
You won't be able to use that with the
withTRPC
-HOC but you can create your own provider, see the docs here https://trpc.io/docs/react