diff --git a/content/400-pulse/200-getting-started.mdx b/content/400-pulse/200-getting-started.mdx index 90d302324e..fe3b973e27 100644 --- a/content/400-pulse/200-getting-started.mdx +++ b/content/400-pulse/200-getting-started.mdx @@ -89,15 +89,38 @@ const prisma = new PrismaClient().$extends( ) ``` -:::warning +#### Runtime-specific imports + +If you're using `"moduleResolution":"bundler"` in your `tsconfig.json` file and your Pulse extension version is `1.2.0` or greater, import the Pulse extension based on your runtime: + + + + + +```ts +import { withPulse } from '@prisma/extension-pulse/node'; +``` + + -You may need to [configure your `tsconfig.json`](/pulse/faq#how-to-configure-tsconfigjson-with-the-pulse-extension) if you see the following error message: + + +```ts +import { withPulse } from '@prisma/extension-pulse/workerd'; +``` + + + + + +:::warning +Using the correct [runtime-specific import](#runtime-specific-imports) prevents the following error: ``` Cannot find module '@prisma/extension-pulse' or its corresponding type declarations. ``` -::: +::: ### 2.3. Create your first Pulse stream diff --git a/content/400-pulse/600-faq.mdx b/content/400-pulse/600-faq.mdx index ba5f743b95..ed85a910bf 100644 --- a/content/400-pulse/600-faq.mdx +++ b/content/400-pulse/600-faq.mdx @@ -60,20 +60,38 @@ No, Pulse is server-side and subscriptions cannot be initiated directly within c To propagate events to the frontend, you can use a WebSocket library like [socket.io](https://socket.io/). -## How can I ensure SSL/TLS encryption works in SSL-only mode with PostgreSQL database and Pulse? +## How do I import the Pulse Client extension when using `"moduleResolution":"bundler"` in my `tsconfig.json`? -If you encounter issues with SSL/TLS encryption while using Pulse, ensure your database server has a valid SSL certificate and append `sslmode=require` to your database connection string in your project environment in [Prisma Data Platform](https://pris.ly/pdp), for example: +If you're using [`"moduleResolution": "bundler"`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler) in your `tsconfig.json` file and your Pulse extension version is `1.2.0` or greater, import the Pulse extension based on your runtime: + + + + +```ts +import { withPulse } from '@prisma/extension-pulse/node'; ``` -postgres://username:password@hostname:port/database?sslmode=require + + + + + +```ts +import { withPulse } from '@prisma/extension-pulse/workerd'; ``` -This [setting](/orm/overview/databases/postgresql#configuring-an-ssl-connection) will enforce SSL/TLS encryption and accept self-signed certificates. + + + + +The Pulse Client extension provides runtime-specific implementations. This approach ensures TypeScript uses the correct type definitions for your target environment and any other multi-entrypoint packages. -## How to configure `tsconfig.json` with the Pulse extension? +Using the correct runtime-specific import prevents the following error: +``` +Cannot find module '@prisma/extension-pulse' or its corresponding type declarations. +``` -If you're using [`"moduleResolution": "bundler"`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler) in your `tsconfig.json` file, you need to -explicitly set [`customConditions`](https://www.typescriptlang.org/tsconfig/#customConditions) to either `node` or `workerd` depending on your target runtime. This will instruct TypeScript to match the correct type definitions of the Prisma Pulse extension, as well as any other packages that expose multiple entrypoints: +Alternatively, you can configure tsconfig.json to set the correct runtime condition: ```js // tsconfig.json @@ -82,15 +100,23 @@ explicitly set [`customConditions`](https://www.typescriptlang.org/tsconfig/#cus // ...other options "target": "es2022", "moduleResolution": "bundler", - "customConditions": ["workerd"] // or "node" + "customConditions": ["node"] // or "workerd" for Cloudflare Workers } } ``` +
+:::note +We recommend this approach when building a package that uses the Prisma Pulse Client extension as a dependency. +::: -This is needed because Prisma Pulse extension offers separate implementations tailored for various runtimes, such as Node.js and Cloudflare Workers. +Both methods ensure the correct runtime-specific types are used and resolve module resolution errors. + +## How can I ensure SSL/TLS encryption works in SSL-only mode with PostgreSQL database and Pulse? -If you don't add this, you may run into the following error when using the `@prisma/extension-pulse` in your application code: +If you encounter issues with SSL/TLS encryption while using Pulse, ensure your database server has a valid SSL certificate and append `sslmode=require` to your database connection string in your project environment in [Prisma Data Platform](https://pris.ly/pdp), for example: ``` -Cannot find module '@prisma/extension-pulse' or its corresponding type declarations. -``` \ No newline at end of file +postgres://username:password@hostname:port/database?sslmode=require +``` + +This [setting](/orm/overview/databases/postgresql#configuring-an-ssl-connection) will enforce SSL/TLS encryption and accept self-signed certificates. \ No newline at end of file diff --git a/static/_redirects b/static/_redirects index 177484127e..482479b552 100644 --- a/static/_redirects +++ b/static/_redirects @@ -576,3 +576,4 @@ /getting-started/setup-prisma/start-from-scratch/mongodb/next-steps-* /docs/getting-started/setup-prisma/start-from-scratch/mongodb/next-steps /getting-started/setup-prisma/add-to-existing-project/relational-databases/next-steps-* /docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/next-steps /getting-started/setup-prisma/add-to-existing-project/mongodb/next-steps-* /docs/getting-started/setup-prisma/add-to-existing-project/mongodb/next-steps +/pulse/faq#how-to-configure-tsconfigjson-with-the-pulse-extension /pulse/faq#how-do-i-import-the-pulse-client-extension-when-using-moduleresolutionbundler-in-my-tsconfigjson