call db directly in next js app router

hey guys im following josh saas tutorial for some insight in this new version of nextjs, and the i came accros this im feeling somewhat uncomfortable about this because before this im using t3 but still in page router and obviously i always use the trpc first to fetch data, my question is will this pattern is safe and will be common in future? thanks!
No description
12 Replies
Anonymous_hacker
Anonymous_hacker14mo ago
Well for fetching dynamic routes it is great but if you wanna use trpc you can also do that in server components you just have to create a trpc client for that.
arete
areteOP14mo ago
any example you can refer me to for call trpc in server components?
Anonymous_hacker
Anonymous_hacker14mo ago
GitHub
crm-software/src/app/_trpc/serverClient.ts at main · anonymous-sher...
Contribute to anonymous-sherlock/crm-software development by creating an account on GitHub.
arete
areteOP14mo ago
thankss!!
Anonymous_hacker
Anonymous_hacker14mo ago
if you have any doubt dm me
arete
areteOP14mo ago
ooo i see it allow us to use the trpc from rsc right? so is there any pros and cons using this pattern when to use and when to not use it?
arete
areteOP14mo ago
if i want to use the example you gave me do i need to change this
No description
Anonymous_hacker
Anonymous_hacker14mo ago
no you don't have to change it here this is only for client side trpc call server side call won't need
arete
areteOP14mo ago
i see so we can have many option rn now right?
Anonymous_hacker
Anonymous_hacker14mo ago
many options for? didn't understand.
arete
areteOP14mo ago
many options to fetch the data since we got the new rsc stuff
Anonymous_hacker
Anonymous_hacker14mo ago
https://github.com/anonymous-sherlock/crm-software/tree/main/src/app/_trpc if you check there are two file one for client.ts which using trpc/reactquery to run on client and another file name serverClient.ts which using batch link to make all call rpc so it won't run on client.
GitHub
crm-software/src/app/_trpc at main · anonymous-sherlock/crm-software
Contribute to anonymous-sherlock/crm-software development by creating an account on GitHub.
Want results from more Discord servers?
Add your server