How to detect window size in Next.js SSR using react hook?
You can avoid calling your detection function in ssr by adding this code: // make sure your function is being called in client side only if (typeof window !== ‘undefined’) { // detect window screen width function } full example from your link: import { useState, useEffect } from ‘react’; // Usage function App() { … Read more