Fetching data directly from prisma

Hi! I am learning about Prisma, and I see that its possible to fetch data from Prisma directly in any page. Is this safe, or should this be avoided? Or should I just fetch the data from my an endpoint accessing Prisma?
4 Replies
RevengeTime
RevengeTimeOP2y ago
Sybatron
Sybatron2y ago
Your prisma client shouldn't stay in the client side in production Do this only for learning in frontend but it should stay server side
RevengeTime
RevengeTimeOP2y ago
Thx for the advice! Does that mean that I have to make an endpoint that fetches the data with prisma, or it it enough to set "use server", to render the page on the server?
oof2win2
oof2win22y ago
everything you are doing there is safe as you are using getServerSideProps. Besides, Prisma would throw an error if you tried fetching in the clientside as it would not be instantaniated on the client
Want results from more Discord servers?
Add your server