Next.js Discord

Discord Forum

Nextjs 13 server component connect to database

Unanswered
Champagne D’Argent posted this in #help-forum
Open in Discord
Avatar
Champagne D’ArgentOP
Hi I am new to nextjs 13 with server components. I already have a postgres server, am I supposed to connect to the database inside my server component?

A bit confused right now. I have a proper connection url to my db.

4 Replies

Avatar
B33fb0n3
You can see default examples how to fetch stuff via a server component here: https://nextjs.org/docs/pages/building-your-application/data-fetching
Avatar
Marchy
I usually use prisma as my ORM. For next, you'll also have to add the globalThis config

https://www.prisma.io/docs/guides/other/troubleshooting-orm/help-articles/nextjs-prisma-client-dev-practices#solution
Avatar
Alfonsus Ardani
yes, you can call fetch() to your db url
Avatar
B33fb0n3
@Champagne D’Argent if that helped you, please mark an answer as solution, like mentioned here: https://nextjs-forum.com/post/1165704563467223181#message-1165704571885195294