Next.js Discord

Discord Forum

How to fetch data from the database with RSC?

Flat-Coated Retriever posted this in #help-forum
Open in Discord
Flat-Coated RetrieverOP
I am new to RSC and the app router, I am looking for some docs on how to use TypeORM and fetch data from a vercel Postgres DB using the app router / React Server Components. Do I still use an API route for this?

2 Replies

You can directly use mutation actions with ORMs using server actions.

That aside i found an issue on GitHub where developers criticized how TypeORM was straying from supporting NextJS:

Do note that the issue is 2 years old however has comments as early as 5 days ago from the time of writing this message. Take it with pinch of salt and maybe try it yourself to see if it works or not.
You can try the docs of server actions on the nextjs doc site or also api routes, but i would personally recommend switching to either Drizzle (its more similar) or to Prisma. Both work quite well with nextjs