@trpc/client

The tRPC client library

@trpc/client downloads @trpc/client version @trpc/client license

@trpc/clientSimilar Packages:

Npm Package Weekly Downloads Trend

3 Years
🌟 Show real-time usage chart on @trpc/client's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of @trpc/client](https://npm-compare.com/img/npm-trend/THREE_YEARS/@trpc/client.png)](https://npm-compare.com/@trpc/client#timeRange=THREE_YEARS)

Cumulative GitHub Star Trend

🌟 Show GitHub stars trend chart on @trpc/client's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of @trpc/client](https://npm-compare.com/img/github-trend/@trpc/client.png)](https://npm-compare.com/@trpc/client)

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
@trpc/client1,000,79239,810606 kB1938 hours agoMIT

README for @trpc/client

tRPC

tRPC

End-to-end typesafe APIs made easy

Demo

@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/client

# Bun
bun add @trpc/client

AI Agents

If you use an AI coding agent, install tRPC skills for better code generation:

npx @tanstack/intent@latest install

Basic Example

import { createTRPCClient, httpBatchLink } from '@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();