Skip to content

Latest commit

 

History

History
36 lines (23 loc) · 1.27 KB

readme.md

File metadata and controls

36 lines (23 loc) · 1.27 KB

Shared Prisma Client Example

You have to publish it to your private (or not?) npm registry and install it as dependency to each project that uses it. Also, you need to install @prisma/client and prisma as dependencies since they are peer dependencies of this package.

Client generation executed on postinstall hook on each project that uses this package, not on publish.

Example:

yarn add @your-npm-scope/prisma-client @prisma/client prisma

or

npm install @your-npm-scope/prisma-client @prisma/client prisma

Another possible way to install it without publishing to npm registry, is to use git url, instead of npm package name: yarn add git+https://github.com/igolka97/shared-prisma-client-example.git with #tagnameOrCommitSHA if needed.

In your code at some microservice:

import { PrismaClient } from '@your-npm-scope/prisma-client'
const db = new PrismaClient()

Bundling

If you're using a bundler, you need to make sure your package is not bundled as it will break the Prisma query engine(s). Either use the bundler config or make a script that copies over the package after bundling.

If you use Next.js v15, you can exclude your package from bundling in the next.config.js:

const nextConfig = {
    serverExternalPackages: ["YOUR_PACKAGE"],
};