@trpc-swr/client
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

trpc-swr

tRPC-ified SWR hooks

Documentation: https://trpc-swr.vercel.app/

Installation

npm install @trpc-swr/client
# Peer deps
npm install swr @trpc/client @trpc/server

Usage

// profile.tsx
import { trpc } from "./trpc";

const Profile = (props: { userId: string }) => {
  const { data, isLoading } = trpc.user.get.useSWR({ id: props.userId });

  return (
    <div>
      Name:{" "}
      {!data && isLoading
        ? "loading..."
        : data
        ? data.name
        : "User does not exist"}
    </div>
  );
};

Readme

Keywords

none

Package Sidebar

Install

npm i @trpc-swr/client

Weekly Downloads

1,234

Version

2.0.1

License

MIT

Unpacked Size

29.9 kB

Total Files

12

Last publish

Collaborators

  • chiefkoshi