Issue: ReferenceError: window is not defined When Running Angular 18 SSR

Posted by: surya on 12 June 2025, 6:07 am EST

  • Posted 12 June 2025, 6:07 am EST

    Hi Team,

    We have integrated Angular 18 with Server-Side Rendering (SSR) using Angular Universal. However, when we try to run the application using the SSR build, we are encountering the following error:

    /Users/shubhamchhapre/Documents/GitHub/zx-report-UI/dist/zx-report/server/vendor.js:678916
    window.arjsViewer = window.arjsViewer || {};
    ^
    ReferenceError: window is not defined


    It appears that the library is trying to access the window object, which is not available in a Node.js environment during SSR.

    Could you please provide guidance on how to use ActiveReportsJS in an Angular SSR setup, or suggest a workaround to prevent this error?

    Looking forward to your support on this issue.

    Thank you

  • Posted 13 June 2025, 3:36 am EST

    Hi Surya,

    I am assuming you are using the ActiveReportsJS Angular component on your server-side. To the best of my knowledge, I am not sure that the Angular Viewer component is supported for server-side rendering. Instead, I will suggest you use the Vanilla JavaScript ActiveReportsJS viewer, and it should work as expected.

    You can learn more about Server-side rendering in ActiveReportsJS here: https://developer.mescius.com/activereportsjs/docs/DeveloperGuide/advanced/server-side-reporting.

    And here’s a sample that implements server-side rendering of reports in NodeJS using ActiveReportsJS JavaScript component: https://github.com/GrapeCity/activereportsjs-samples/tree/main/arjs-server-mode.

    Regards,

    Anand

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels