Hi,
I was wondering how to get window.innerWidth or window.innerheigth to get viewport sizes since I get errors if I call window.innerWidth inside a component.
the errors:
Uncaught TypeError: window.innerHeight is not a function
Uncaught TypeError: window.innerWidth is not a function
What are you trying to achieve? Because you can use 100vh and 100vw in CSS. Which will allow you to size components to the browser viewport.
1 Like
Hi @jacopo.bombardieri
Frontity needs to run on both server-side and client-side. The window
object doesn’t exist server-side, so you may need to wrap your code that gets the viewport size in one of the actions that only run on the client, such as afterCSR
.
See our docs here for more info.