Getting 'TypeError: win.matchMedia is not a function' when i try to start ionic app with SSR in Angular

Viewed 380

I have ionic PWA application with SSR. When i try to start 'dev:ssr' i've got "TypeError: win.matchMedia is not a function".

const isPWA = (win) => !!(win.matchMedia('(display-mode: standalone)').matches || win.navigator.standalone);

this row inside server/main.js file

1 Answers

For future readers, I think I found the solution to this error: components running on Server side cannot contain ngAfterViewInit, ionViewWillEnter and others. In my case it was giving error with ionic 5 / angular 10

Related