Package Exports
- @trpc/client
- @trpc/client/links/httpBatchLink
- @trpc/client/links/httpLink
- @trpc/client/links/loggerLink
- @trpc/client/links/splitLink
- @trpc/client/links/wsLink
- @trpc/client/package.json
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@trpc/client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
tRPC
End-to-end typesafe APIs made easy
@trpc/client
Communicate with a tRPC server on the client side.
Documentation
Full documentation for @trpc/client can be found here
Installation
# npm
npm install @trpc/client
# Yarn
yarn add @trpc/client
# pnpm
pnpm add @trpc/clientBasic Example
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
// Importing the router type from the server file
import type { AppRouter } from './server';
// Initializing the tRPC client
const trpc = createTRPCProxyClient<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();