P
Prisma4mo ago
Marceau

What is the recommended way to use Prisma types on the front-end?

I'm mostly asking this because, while using Prisma.<Model>GetPayload and something like nitropack's SerializeObject type utility works fine, it feels cumbersome and more importantly, it seems to bring the performance of the editor's TypeScript language server down to a crawl, which impedes the pace of development massively. So I am wondering what's the best way to interface with Prisma types on the client, considering that the data received from the server will be serialized, meaning the generated types won't match as the returned output.
2 Replies
Prisma AI Help
Prisma AI Help4mo ago
You're in no rush, so we'll let a dev step in. Enjoy your coffee, or drop into #ask-ai if you get antsy for a second opinion!
Nurul
Nurul4mo ago
If I understand correctly you only want to export specific prisma types to frontend and not all the types, right? Have you considered using something like? https://www.npmjs.com/package/zod-prisma-types
npm
zod-prisma-types
Generates zod schemas from Prisma models with advanced validation. Latest version: 3.2.4, last published: 3 months ago. Start using zod-prisma-types in your project by running npm i zod-prisma-types. There are 9 other projects in the npm registry using zod-prisma-types.

Did you find this page helpful?