custom query function

I have a use case where I need a trpc procedure call when a specific key is not present in the local storage else I return the data in the local storage. Can this be doable without relying on the vanilla react-query hook ?
You could use a custom hook and toggle the enabled flag on the query?