Nextjs 13 server component connect to database
Unanswered
Champagne D’Argent posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
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.
A bit confused right now. I have a proper connection url to my db.
4 Replies
![Avatar](https://cdn.discordapp.com/avatars/301376057326567425/788b75eb8862277af3d31d317ada783f.webp?size=256)
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](https://cdn.discordapp.com/avatars/203709756689350656/e1e7ff9d4bca9af62a5674dadadb32cc.webp?size=256)
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
https://www.prisma.io/docs/guides/other/troubleshooting-orm/help-articles/nextjs-prisma-client-dev-practices#solution
![Avatar](https://cdn.discordapp.com/avatars/194128415954173952/708a8637ada505b6b7a85972807d9dca.webp?size=256)
Alfonsus Ardani
yes, you can call fetch() to your db url
![Avatar](https://cdn.discordapp.com/avatars/301376057326567425/788b75eb8862277af3d31d317ada783f.webp?size=256)
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