Conversation
|
@microsoft-github-policy-service agree |
| "yargs": "^16.1.0" | ||
| }, | ||
| "dependencies": { | ||
| "crypto": "^1.0.1", |
There was a problem hiding this comment.
crypto-js works front and backend would this be a better option here for the same purpose? or it doesn't matter in this case?
There was a problem hiding this comment.
It serves the same purpose as window.crpyo. Its just that it does not use window object of JS and uses this npm package for crypto
is this solution only related to NextJS 13 pages or 14 app directory also? |
I tried using 'use client', didn't solve the issue. Probably because initial html pages still get loaded on server side |
And this didn't work either? const Component = dynamic(() => import('~/[path]'), {
loading: () => null,
ssr: false // default value is false just being explicit
} |
Nope, it didn't. Will check it in their framework too! |
Thanks for entertaining my curiosity! 🙌 |
|
@mattmazzola mind reviewing this? |
The code here uses window object of JS in some places, which is not defined in SSR frameworks like NextJSm which could not be solved on client side by using common solutions like lazy loading and dynamic imports.
Here, I've fixed the issue by replacing window object attributes (crpyo and self) by a third party npm library to prevent any issues in nextJS integration.
Please note that many libraries like powerbi-client-react uses this as dependency, which may cause problems in integration with nextJS. There are many solutions on stack overlflow regarding this error: Reference Error: self is not defined, but having personally tried all of them, none of it seemed to work