Experiments with tRPC and Nuxt Server API
This commit is contained in:
14
plugins/trpc.ts
Normal file
14
plugins/trpc.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { createTRPCNuxtClient, httpBatchLink } from 'trpc-nuxt/client';
|
||||
import type { AppRouter } from '~/server/trpc/routers';
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
const trpc = createTRPCNuxtClient<AppRouter>({
|
||||
links: [httpBatchLink({ url: '/api/trpc' })],
|
||||
});
|
||||
|
||||
return {
|
||||
provide: {
|
||||
trpc,
|
||||
},
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user