Replies: 2 comments 3 replies
-
So you can just create the trpc client anywhere and then import it anywhere. And that will be like your global variable. Then for trpc-vue-query you can do import { client } from './your-path-to-trpc'
createTrpcVueClient(client, useQueryClient()) As for supporting typescript in Nuxt I'm not sure what you're asking for as I have typescript working in multiple Nuxt projects. If you're IDE doesn't have typescript working it could be related to the Vue (Volar) extension upgrading to V2. Check out their issues |
Beta Was this translation helpful? Give feedback.
-
So you can't create the trpcVueClient outside of the Nuxt context, because @tanstack/vue-query needs access to that context. You should create it in a nuxt plugin. If however you need access to trpc's client then you can create that in ~/utils/api.ts and then import it and pass it to |
Beta Was this translation helpful? Give feedback.
-
I'd like the more convenient way, rather than through the useNuxtApp composables.
Beta Was this translation helpful? Give feedback.
All reactions