JSPM

@trpc/client

10.0.0-alpha-katt-more-play-2022-09-04-19-42-36.2+7d29bda8
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1284183
  • Score
    100M100P100Q228310F
  • License MIT

tRPC Client lib

Package Exports

  • @trpc/client
  • @trpc/client/links/httpBatchLink
  • @trpc/client/links/httpLink
  • @trpc/client/links/loggerLink
  • @trpc/client/links/splitLink
  • @trpc/client/links/wsLink

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

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@next

# Yarn
yarn add @trpc/client@next

# pnpm
pnpm add @trpc/client@next

Basic Example

import { createTRPCClient, createTRPCClientProxy } from '@trpc/client';
// Importing the router type from the server file
import type { AppRouter } from './server';

// Initializing the tRPC client
const client = createTRPCClient<AppRouter>({
  url: 'http://localhost:2022',
});

// Creating a proxy, this allows for cmd+click to the backend function.
const proxy = createTRPCClientProxy(client);

async function main() {
  // Querying the greeting
  const helloResponse = await proxy.greeting.query({
    name: 'world',
  });

  console.log('helloResponse', helloResponse); // Hello world
}

main();