diff --git a/docs/platforms/javascript/common/best-practices/web-workers.mdx b/docs/platforms/javascript/common/best-practices/web-workers.mdx index 1f7b9ba14a5a72..180d9aa5b72147 100644 --- a/docs/platforms/javascript/common/best-practices/web-workers.mdx +++ b/docs/platforms/javascript/common/best-practices/web-workers.mdx @@ -176,4 +176,32 @@ export default defineConfig({ plugins: () => [...sentryPlugin], }, }); -``` \ No newline at end of file +``` + +### SSR gotchas + +When using SSR, make sure to only run `addIntegration` in a browser context. + +Here's a Vite example : + +```ts +import workerUrl from "./my-worker?worker&url" + +const worker = new Worker(new URL(workerUrl, import.meta.url), { type: "module" }) +if (!import.meta.env.SSR) { + Sentry.addIntegration(Sentry.webWorkerIntegration({ worker })) +} +``` + +Refer to your framework documentation to know how to remove code from the server bundle. + +For example, with Nuxt you can use : + +```ts +import workerUrl from "./my-worker?worker&url" + +const worker = new Worker(new URL(workerUrl, import.meta.url), { type: "module" }) +if (import.meta.client) { + Sentry.addIntegration(Sentry.webWorkerIntegration({ worker })) +} +```