Navigator is undefined when used with NextJS

Getting ReferenceError: navigator is not defined

I’ve tried to NoSSR
I’ve tried to follow this GitHub - trungdq88/nextjs-phaser but it keeps throwing:
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports.

Since NextJS generates HTML structure on server and then hydrates them on client’s device, some part of React Components get executed on server where native browser stuff are undefined.
I’m suspescting phaser library running on server is causing error, Therefore make sure that all of Phaser’s code is executed inside useEffect hook.
Not only Initializing Phaser.Game inside useEffect but whole library because phaser automatically does some checks in background. for achieving that use require or dynamic import to importing game code