Samir Thapa - Hello, I'm currently embedding ...

Hello, I'm currently embedding ThoughtSpot Visual Embed SDK using NextJS 15. While it was working fine previously, it now shows the following error when running the app::
Uncaught ReferenceError: window is not defined
at storeValueInWindow (file://<project-path>/node_modules/@thoughtspot/visual-embed-sdk/cjs/src/utils.js:314:5)
at createAndSetInitPromise (file://<project-path>/node_modules/@thoughtspot/visual-embed-sdk/cjs/src/embed/base.js:141:36)
at Object.<anonymous> (file://<project-path>/node_modules/@thoughtspot/visual-embed-sdk/cjs/src/embed/base.js:147:37)
at Module._compile (node:internal/modules/cjs/loader:1562:14)
at Object..js (node:internal/modules/cjs/loader:1699:10)
at Module.load (node:internal/modules/cjs/loader:1313:32)
at Function._load (node:internal/modules/cjs/loader:1123:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.<anonymous> (node:internal/modules/cjs/loader:1335:12)
at mod.require (file://<project-path>/node_modules/next/dist/server/require-hook.js:65:28)
at require (node:internal/modules/helpers:136:16)
at Object.<anonymous> (file://<project-path>/node_modules/@thoughtspot/visual-embed-sdk/cjs/src/utils/processData.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1562:14)
at Object..js (node:internal/modules/cjs/loader:1699:10)
Uncaught ReferenceError: window is not defined
at storeValueInWindow (file://<project-path>/node_modules/@thoughtspot/visual-embed-sdk/cjs/src/utils.js:314:5)
at createAndSetInitPromise (file://<project-path>/node_modules/@thoughtspot/visual-embed-sdk/cjs/src/embed/base.js:141:36)
at Object.<anonymous> (file://<project-path>/node_modules/@thoughtspot/visual-embed-sdk/cjs/src/embed/base.js:147:37)
at Module._compile (node:internal/modules/cjs/loader:1562:14)
at Object..js (node:internal/modules/cjs/loader:1699:10)
at Module.load (node:internal/modules/cjs/loader:1313:32)
at Function._load (node:internal/modules/cjs/loader:1123:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.<anonymous> (node:internal/modules/cjs/loader:1335:12)
at mod.require (file://<project-path>/node_modules/next/dist/server/require-hook.js:65:28)
at require (node:internal/modules/helpers:136:16)
at Object.<anonymous> (file://<project-path>/node_modules/@thoughtspot/visual-embed-sdk/cjs/src/utils/processData.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1562:14)
at Object..js (node:internal/modules/cjs/loader:1699:10)
As per my understanding, the SDK is mounting over the server side which is causing this error. Any sort of insight or help would be appreciated! Thanks
6 Replies
Samir Thapa
Samir ThapaOP2mo ago
Even retried with a fresh NextJS project. Importing from @thoughtspot/visual-embed-sdk shows an error right away: // import { init } from "@thoughtspot/visual-embed-sdk"; export default function Home() { return <div>Test</div>; }
yuichirio_ha
yuichirio_ha2mo ago
Hey @Samir Thapa , What was the older sdk version that you were using ? ( working one ) Yes just checked.
Samir Thapa
Samir ThapaOP2mo ago
older one was this : 1.33.9 but even this version is showing the error now
yuichirio_ha
yuichirio_ha2mo ago
yeah, @Samir Thapa . I will get back to you on this. Hey @Samir Thapa , Can we revert to : 1.32.0 for now? Thanks. based on the recent changes to the SDK, I recommend using the ThoughtSpot Visual Embed SDK exclusively on the client side moving forward. This will help avoid issues related to server-side rendering. I will discuss this further with my team and get back to you with any additional insights or recommendations.
Samir Thapa
Samir ThapaOP2mo ago
thanks and for now it's working
yuichirio_ha
yuichirio_ha3w ago
Hey, Can you do all the sdk related stuff on the client side? That should be how sdk used. Most of the code will need client side. https://codesandbox.io/p/sandbox/next-js-starter-vesdk-rnf9mm Check out this - it will work with latest sdk. And upgrade to latest sdk. Hey @Samir Thapa , Can you confirm the nextjs version you were using previously, you have now nextjs 15 as you told.

Did you find this page helpful?