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
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
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?
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