@uni-helper/trpc-client
v0.0.1-beta.7
Published
The tRPC uni-app client library
Readme
@uni-helper/trpc-client
兼容uni-app的trpc客户端.
Documentation
查阅@trpc/client的完整文档,请访问这里。
Installation
# npm
npm install @uni-helper/trpc-client
# Yarn
yarn add @uni-helper/trpc-client
# pnpm
pnpm add @uni-helper/trpc-client
# Bun
bun add @uni-helper/trpc-clientBasic Example
import { createTRPCClient, httpBatchLink } from '@uni-helper/trpc-client'
// Importing the router type from the server file
import type { AppRouter } from './server'
// Initializing the tRPC client
const trpc = createTRPCClient<AppRouter>({
links: [
httpBatchLink({
url: 'http://localhost:3000/trpc',
}),
],
})
async function main() {
// Querying the greeting
const helloResponse = await trpc.greeting.query({
name: 'world',
})
console.log('helloResponse', helloResponse) // Hello world
}
main()