diff --git a/README.md b/README.md
index 6cbd662..27e6943 100644
--- a/README.md
+++ b/README.md
@@ -58,24 +58,6 @@ Use the client like so:
-```
-
-## Composables
-
-Composables are auto-imported.
-
-### `useClient()`
-
-A typesafe client with the `createTRPCClient` method from `@trpc/client`.
-
-```html
-
```
-
-### `useClientQuery`
-
-`client.query` wrapped in [`useAsyncData`](https://v3.nuxtjs.org/guide/features/data-fetching/#useasyncdata).
-
-```html
-
-```
-
-### `useLazyClientQuery`
-
-`client.query` wrapped in [`useLazyAsyncData`](https://v3.nuxtjs.org/guide/features/data-fetching/#uselazyasyncdata).
-
-```html
-
-```
-
diff --git a/client.d.ts b/client.d.ts
deleted file mode 100644
index 047203f..0000000
--- a/client.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './dist/runtime/client'
diff --git a/package.json b/package.json
index 1dc0d3a..a96e276 100644
--- a/package.json
+++ b/package.json
@@ -15,10 +15,6 @@
"./api": {
"import": "./dist/runtime/api.mjs",
"types": "./dist/runtime/api.d.ts"
- },
- "./client": {
- "import": "./dist/runtime/client.mjs",
- "types": "./dist/runtime/client.d.ts"
}
},
"files": [
@@ -39,7 +35,6 @@
"@trpc/server": "^9.23.2",
"fs-extra": "^10.1.0",
"h3": "^0.7.8",
- "ohash": "^0.1.0",
"pathe": "^0.3.0",
"ufo": "^0.8.4"
},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a68c901..fabe49a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -16,7 +16,6 @@ importers:
fs-extra: ^10.1.0
h3: ^0.7.8
nuxt: ^3.0.0-rc.3
- ohash: ^0.1.0
pathe: ^0.3.0
pnpm: ^7.1.0
trpc-nuxt: workspace:*
@@ -28,7 +27,6 @@ importers:
'@trpc/server': 9.23.4
fs-extra: 10.1.0
h3: 0.7.8
- ohash: 0.1.0
pathe: 0.3.0
ufo: 0.8.4
devDependencies:
@@ -4668,6 +4666,7 @@ packages:
/ohash/0.1.0:
resolution: {integrity: sha512-KvclyhWseX6F2UTEEp9Qzybb0LTGorTSVufAToV5tR2B6Q64rVhKhkcU/o+mBaiqGa5+PdobtfSVelp8VOCR6A==}
+ dev: true
/ohmyfetch/0.4.17:
resolution: {integrity: sha512-jUpCDJIDlTZdS4PE3veoHIXoUSm2NRJfFMIROd29/qeOsbJEoEYBzJ6re+W1hskc44ej11IL//scfhckIcCN8Q==}
diff --git a/src/module.ts b/src/module.ts
index 122d8c1..eded389 100644
--- a/src/module.ts
+++ b/src/module.ts
@@ -15,10 +15,6 @@ export default defineNuxtModule({
const clientPath = join(nuxt.options.buildDir, 'trpc-client.ts')
const handlerPath = join(nuxt.options.buildDir, 'trpc-handler.ts')
- nuxt.hook('config', (options) => {
- options?.build?.transpile?.push('trpc-nuxt/client')
- })
-
addServerHandler({
route: '/trpc/*',
handler: handlerPath,
@@ -26,8 +22,6 @@ export default defineNuxtModule({
nuxt.hook('autoImports:extend', (imports) => {
imports.push(
- { name: 'useTrpcQuery', from: clientPath },
- { name: 'useLazyTrpcQuery', from: clientPath },
{ name: 'useClient', from: clientPath },
)
})
@@ -36,22 +30,15 @@ export default defineNuxtModule({
await fs.writeFile(clientPath, `
import * as trpc from '@trpc/client'
- import { createTRPCComposables } from 'trpc-nuxt/client'
import type { router } from '~/trpc'
const client = trpc.createTRPCClient({
url: process.browser ? '/trpc' : 'http://localhost:3000/trpc',
})
-
- const {
- useClientQuery,
- useLazyClientQuery,
- useClient
- } = createTRPCComposables(client)
+
+ const useClient = () => client
export {
- useClientQuery,
- useLazyClientQuery,
useClient
}
`)
diff --git a/src/runtime/client.ts b/src/runtime/client.ts
deleted file mode 100644
index d372934..0000000
--- a/src/runtime/client.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { objectHash } from 'ohash'
-import type { TRPCClient } from '@trpc/client'
-import type { AnyRouter, inferProcedureInput, inferProcedureOutput } from '@trpc/server'
-import type { AsyncData, KeyOfRes, PickFrom, _Transform } from 'nuxt/dist/app/composables/asyncData'
-// @ts-expect-error: Resolved by Nuxt
-import { useAsyncData, useLazyAsyncData } from '#imports'
-
-export function createTRPCComposables<
- Router extends AnyRouter,
- Client extends TRPCClient = TRPCClient,
- TQuery extends keyof Router['_def']['queries'] = keyof Router['_def']['queries'],
->(
- client: Client
-): {
- useClientQuery: <
- TRouteKey extends TQuery,
- ProcedureInput = inferProcedureInput,
- ProcedureOutput = inferProcedureOutput,
- >(
- path: TRouteKey,
- input: ProcedureInput
- ) => AsyncData<
- PickFrom<
- ProcedureOutput,
- KeyOfRes<_Transform>
- >,
- true | Error
- >
- useLazyClientQuery: <
- TRouteKey extends TQuery,
- ProcedureInput = inferProcedureInput,
- ProcedureOutput = inferProcedureOutput,
- >(
- path: TRouteKey,
- input: ProcedureInput
- ) => AsyncData<
- PickFrom<
- ProcedureOutput,
- KeyOfRes<_Transform>
- >,
- true | Error
- >
- useClient: () => Client
-}
-
-export function createTRPCComposables(client) {
- const useClientQuery = (...args) => {
- return useAsyncData(`trpc-${objectHash(args[0] + (args[1] ? JSON.stringify(args[1]) : ''))}`, () => client.query(...args))
- }
-
- const useLazyClientQuery = (...args) => {
- return useLazyAsyncData(`trpc-${objectHash(args[0] + (args[1] ? JSON.stringify(args[1]) : ''))}`, () => client.query(...args))
- }
-
- const useClient = () => client
-
- return {
- useClientQuery,
- useLazyClientQuery,
- useClient,
- }
-}