# trpc-layout

> Resolve TRPC queries to JSX. Stop littering your project with isSuccess, isLoading and isError.

Latest version **0.0.4** (published 2023-05-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install trpc-layout
pnpm add trpc-layout
yarn add trpc-layout
bun add trpc-layout
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2023-05-04 |
| First published | 2023-05-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 18.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | branch |

## Links

- npm: https://www.npmjs.com/package/trpc-layout
- Repository: https://github.com/MaximilianLloyd/TRPC-layout
- Homepage: https://github.com/MaximilianLloyd/TRPC-layout#readme
- Issues: https://github.com/MaximilianLloyd/TRPC-layout/issues
- npm.io page: https://npm.io/package/trpc-layout

## Dependencies (2)

- [react](https://npm.io/package/react.md) ^18.2.0
- [@trpc/react-query](https://npm.io/package/@trpc/react-query.md) ^10.25.0

## Recent versions

- 0.0.4 (latest) — 2023-05-04
- 0.0.3 — 2023-05-04

## README

# TRPC-Layout

Resolve TRPC queries to JSX. Stop littering your project with isSuccess, isLoading and isError.


## Installation

```sh
$ npm i trpc-layout
# or
$ pnpm add trpc-layout
# or
$ yarn add trpc-layout
```


## Example

Turn this:

```tsx
const { data, isSuccess, isError, isLoading } = api.example.hello.useQuery();

if (isLoading) {
  return <Loading />;
}

if (isError) {
  return <div>Something happened</div>;
}

if (isSuccess) {
  return <div>{data.name}</div>;
}

return null;
```

Into this:

```tsx
import { TRPCLayout } from "trpc-layout";

const query = api.example.hello.useQuery();

// Data and error are inferred from the query
return TRPCLayout(query, {
  success(data) {
    return <div>{data.name}</div>;
  },
  error(error) {
    return <div>{error.message}</div>;
  },
  loading: <Loading />,
});
```

---
_Source: https://npm.io/package/trpc-layout · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
