Next.js Discord

Discord Forum

Help adapting Prisma examples to work with the recommended: Route Handlers or Server components

Unanswered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
Hello I'm trying to make the Prisma example: Rest NextJS to work with the recommended: Route Handlers or Server components for the new App Router, But with no luck since I'm new to NextJS orPrisma.

Can you please share an example of how to make it work with the new App Router recommendations instead of the hybrid way it's using currently with App Router + Api Routes.

https://github.com/prisma/prisma-examples/tree/latest/typescript/rest-nextjs-api-routes

10 Replies

@West African Lion can you plz tell me what's your trouble in detail?
With app router, hmm you can use prisma inside server components
like you had to have data fetching in the api routes in the page router, but in app router you can have that directly inside server components
West African LionOP
I need a working example of how to do it, since I'm new to both frameworks, and the current example is using App Router + Api Routes instead of the recommended way of App Router + Route Handler or Server Components, I tried to do it myself but with no luck, so can you please please provide a working version of the Prisma example.

I tried to copy the code from the Api Routes into a route.tsx file but i'm getting errors.
And I have no idea of how to make it work with the new recommended methods
@James4u 👆
I'm trying to learn by example, so sorry in advance if that's too much to ask
West African LionOP
Thank you for the links, checking them right now