P
Prisma3mo ago
Niels

Using the new `prisma-client` with NextJS

It it normal that the new prisma client isn't compatible with the browser? When using prisma models in my client side next components, I get Cannot find module 'node:fs': Unsupported external type Url for commonjs reference
7 Replies
Prisma AI Help
Prisma AI Help3mo ago
You selected the bot's instantaneous insights. Let me compile your answer right away! Short answer: yes—this is expected today. - Prisma Client itself does not run in the browser. You must use it only on the server (Route Handlers, Server Components, getServerSideProps, API routes). If Prisma code is bundled for the client, you’ll see errors like the ones you’re getting. [Comment summary; Next.js guidance] - With the new prisma-client generator, a dedicated browser entry point was added to let you import types and utilities in browser code without pulling Node APIs—but it intentionally does not include PrismaClient. You can safely import types like enums, Prisma.JsonValue, Decimal, etc., from the generated browser entry instead of importing from the server client. [feat: browser.ts; [Issue context] What to do in Next.js: - Keep all PrismaClient usage in server-only files (e.g., server actions with "use server", route handlers, or getServerSideProps). [Next.js notes; [Guidance] - For client components that need types (model enums, Prisma.JsonValue), import them from the generated browser entry introduced by the new generator, not from @prisma/client. This avoids bundling Node modules like node:fs. [feat: browser.ts; [Issue] If you still see node:fs errors, it likely means something is importing the server client/runtime into the client bundle—move those imports to server-only modules or switch to the browser types entry. [Issue] ✅ Great, thanks for letting us know that this solved your question!
Niels
NielsOP3mo ago
How do I use the new prisma.config.ts file? @Prisma AI Help How do I use the new prisma.config.ts fil?
Nurul
Nurul3mo ago
You can use #ask-ai to ask questions to the chat bot. Docs for prisma.config file: https://www.prisma.io/docs/orm/reference/prisma-config-reference
Reference documentation for the prisma config file | Prisma Documen...
This page gives an overview of all Prisma config options available for use.
Niels
NielsOP3mo ago
Ah!! Thanks, the channel was hidden for some reason.
Nurul
Nurul3mo ago
Strange!
Niels
NielsOP3mo ago
No description
Nurul
Nurul3mo ago
Oh, let me check if we can add #ask-ai added as default in Channel list

Did you find this page helpful?