With the release of version 4.16.0 of the Prisma ORM, Client extensions are now Generally Available! This new feature allows users to extend and customize Prisma Client to meet their individual use cases.
Tailor Prisma Client to meet your codebase's needs
In 4.7.0, we released Prisma Client extensions as a Preview feature. Today we are happy to announce the General Availability of Prisma Client extensions! Extensions have proven to be extremely useful and powerful during the Preview period, even powering Prisma products like Accelerate and Optimize!
A straightforward and easy to use API
If this is the first time you're hearing about Client extensions, don't worry. We have an existing blog post that covers the usage in-depth. To sum it up here: creating an extension is as easy as using $extends
.
This code snippet shows how you can add a new method to the User
model using a model
extension:
If you instead require a method on all models, you can even use the builtin $allModels
feature:
For a more in-depth look into changes we made to the extensions API as a part of this release, please check out our release notes
Extensions built by the community
While client extensions are now generally available, we have already seen some cool examples in the wild. prisma-extension-pagination
is an awesome contribution from our community. Importing and using an external client extension is easy too:
Reference examples for various use cases
In addition to community contributions, we have a set of reference examples in the prisma-client-extensions
example repository that showcase different areas where we believe Prisma Client extensions can be useful. The repository currently contains the following example extensions:
save()
and delete()
to result objectsShow off your extensions!
If you'd like a deeper dive into Prisma Client extensions, be sure to check out our previous write-up: Prisma Client Just Became a Lot More Flexible: Prisma Client Extensions!
We'd also love to hear about your extensions (and maybe even take them for a spin).
Be sure to show of your #MadeWithPrisma
work in our Discord
Donโt miss the next post!
Sign up for the Prisma Newsletter