Tanstack Query Integration For Vue
This guide shows how to integrate oRPC with Tanstack Query for Vue. For an introduction, please review the Basic Guide first.
Installation
sh
npm install @orpc/vue-query@latest @tanstack/vue-query@latest
sh
yarn add @orpc/vue-query@latest @tanstack/vue-query@latest
sh
pnpm add @orpc/vue-query@latest @tanstack/vue-query@latest
sh
bun add @orpc/vue-query@latest @tanstack/vue-query@latest
sh
deno install npm:@orpc/vue-query@latest npm:@tanstack/vue-query@latest
Setup
Before you begin, ensure you have already configured a server-side client or a client-side client.
ts
import { createORPCVueQueryUtils } from '@orpc/vue-query'
export const orpc = createORPCVueQueryUtils(client)
orpc.planet.find.queryOptions({ input: { id: 123 } })
//
Avoiding Query/Mutation Key Conflicts
Prevent key conflicts by passing a unique base key when creating your utils:
ts
const userORPC = createORPCVueQueryUtils(userClient, {
path: ['user']
})
const postORPC = createORPCVueQueryUtils(postClient, {
path: ['post']
})