A lot of WHY
Great post from @cje on Twitter but also got a lot of questions
1. If the data flow starts from
server/api/routers/examples.ts
, why is the create-t3-app
documentation starts from pages/api/trpc/[trpc].ts
? Is there specific reason for that? Or is it just a big massive loop that has no starts and ends?
2. When you say Next.js hands the request to tRPC, shouldn't it be from pages/[somepage]/*.tsx
-> page/api/[someapi]
->server/trpc.ts
-> server/trpc/*.ts
or some server/db/*.ts
?
3. Why do we need utils/api.ts
? Why not just define the data flow and React Query Hooks in server/*/*.ts
? Why not just import router type and enable superjson
in pages/api/*.ts
?
4. When you say Shape of API
, what could be the shape
of api
? You meant the input/output type and types of procedures?![](https://utfs.io/f/f9c62474-3ad0-4b08-9408-def7f53f848f-clzle.jpeg)
3 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
and you can possibly get some examples in to understand the syntax better
![](https://utfs.io/f/d74fd143-0668-4b41-aefe-6881f764e4ec-mfsbj2.13.28.png)
ahah if it starts from
useQuery
why do you put it at the bottom hahah human visual system starts at 1/3 on a page, the place you put middleware
is actually where naturally people would look at first