Issue
import { registerLicense } from '@syncfusion/ej2-base';
// ...
registerLicense(syncFusionLicenseKey);
Leads to errors during Server-Side Rendering in NextJS14:
⨯ ReferenceError: window is not defined
How to reproduce
Prepare a standard NextJS14 project. Copy the code above in one of the routable page.tsx path. Visit that path.
Given the issue, I don't think it's isolated to NextJS14, I think any component that uses SSR would have the same issue.
Current workaround
Load the component dynamically and disable SSR:
const MyEj2Component = dynamic(() => import('./my-ej2-component'), {
ssr: false,
});
When did this issue occur?
Issue started to occur when we switched to:
"@syncfusion/ej2-react-navigations": "^31.1.20",
"@syncfusion/ej2-react-schedule": "^31.1.21",
Previously using:
"@syncfusion/ej2-react-navigations": "^30.2.7",
"@syncfusion/ej2-react-schedule": "^30.2.7",
Other solutions explored
- Upgrading to the latest version did not work
- Calling
registerLicense during useLayoutEffect did not work
Additional information
package.json engines, dependencies:
"engines": {
"npm": ">=10.0.0",
"node": "^22.18.0"
},
"dependencies": {
"next": "^14.2.32",
"react": "^18.3.1",
}