@sskmy1024y/trpc-swr-client
v1.0.3-beta.0
Published
[tRPC](https://trpc.io/)-ified [SWR](https://swr.vercel.app/) hooks
Downloads
6
Readme
trpc-swr
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>
);
};