add nuxt and expo with orpc

This commit is contained in:
Aman Varshney
2025-04-23 13:03:38 +05:30
parent 49c7d4f436
commit d3a80b7e63
145 changed files with 2013 additions and 874 deletions

View File

@@ -0,0 +1,35 @@
import { defineNuxtPlugin, useRuntimeConfig } from '#app'
import type { RouterClient } from '@orpc/server'
import type { appRouter } from "../../../server/src/routers/index";
import { createORPCClient } from '@orpc/client'
import { RPCLink } from '@orpc/client/fetch'
import { createORPCVueQueryUtils } from '@orpc/vue-query'
export default defineNuxtPlugin(() => {
const config = useRuntimeConfig()
const serverUrl = config.public.serverURL
const rpcUrl = `${serverUrl}/rpc`;
const rpcLink = new RPCLink({
url: rpcUrl,
{{#if auth}}
fetch(url, options) {
return fetch(url, {
...options,
credentials: "include",
});
},
{{/if}}
})
const client: RouterClient<typeof appRouter> = createORPCClient(rpcLink)
const orpcUtils = createORPCVueQueryUtils(client)
return {
provide: {
orpc: orpcUtils
}
}
})