Serverside Rendering (Angular Universal)

I need serverside rendering for SEO in one of my apps. With the feature mention:
ssr: add @ionic/core/hydrate app in ionic 4.7 nitrogen I was very hopeful. I created a new tabs project and added Angular Universal like this:
ng add @nguniversal/express-engine --clientProject app
but when I try to run npm run build:ssr && npm run serve:ssr
I get window reference errors:

const win = window;
            ^

ReferenceError: window is not defined

ionic info:

Ionic:

   Ionic CLI                     : 5.2.3 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.7.1
   @angular-devkit/build-angular : 0.801.2
   @angular-devkit/schematics    : 8.1.2
   @angular/cli                  : 8.1.2
   @ionic/angular-toolkit        : 2.0.0

Utility:

   cordova-res : not installed
   native-run  : 0.2.7 (update available: 0.2.8)

System:

   NodeJS : v10.13.0 (/usr/local/bin/node)
   npm    : 6.10.2
   OS     : macOS Mojave

Maybe Iā€™m doing something wrong? Thanks!

1 Like

I have the same problem, have you solved it?

Hi.Di you solved this ? I had same error ?

Hi.Di you solved this ? I had same error ??

Is anyone solved this already? I having the same error and I can find any solution on the web. :frowning:

1 Like

Jaja you cannot use window in server, ssr basics!! Server is not the browser.