title: Next.js (React) + Phaser: ReferenceError: navigator is not defined
body: <p>I'm trying to use <code>phaser</code> along with <code>ion-phaser/react</code> to build a page with a game in a Next.js app. This is my <code>pages/game.js</code> (using the React example from here <a href="https://github.com/proyecto26/ion-phaser" rel="nofollow noreferrer">https://github.com/proyecto26/ion-phaser</a>):</p>
  <pre><code>import React, { Component } from 'react'
  import Phaser from 'phaser'
  import { IonPhaser } from '@ion-phaser/react'
  
  class App extends Component {
    state = {
      initialize: false,
      game: {
        width: &quot;100%&quot;,
        height: &quot;100%&quot;,
        type: Phaser.AUTO,
        scene: {}
      }
    }
    render() {
      const { initialize, game } = this.state
      return (
        &lt;IonPhaser game={game} initialize={initialize} /&gt;
      )
    }
  }
  
  export default App;
  </code></pre>
  <p>Running <code>next dev</code> and visiting the page gives the following error:</p>
  <pre><code>ReferenceError: navigator is not defined
  
  This error happened while generating the page. Any console logs will be displayed in the terminal window.
  Call Stack
  init
  file:///C:/git_projects/game/node_modules/phaser/src/device/OS.js (69:14)
  Object.&lt;anonymous&gt;
  file:///C:/git_projects/game/node_modules/phaser/src/device/OS.js (186:18)
  Module._compile
  internal/modules/cjs/loader.js (1063:30)
  Object.Module._extensions..js
  internal/modules/cjs/loader.js (1092:10)
  Module.load
  internal/modules/cjs/loader.js (928:32)
  Function.Module._load
  internal/modules/cjs/loader.js (769:14)
  Module.require
  internal/modules/cjs/loader.js (952:19)
  require
  internal/modules/cjs/helpers.js (88:18)
  Object.&lt;anonymous&gt;
  file:///C:/git_projects/floam/node_modules/phaser/src/device/index.js (32:9)
  Module._compile
  internal/modules/cjs/loader.js (1063:30)
  </code></pre>
  <p>Why is <code>navigator</code> not defined?</p>
  <p>These are my relevant package versions in <code>package.json</code>:</p>
  <pre><code>&quot;next&quot;: &quot;^9.5.5&quot;,
  &quot;react&quot;: &quot;^16.5.2&quot;,
  &quot;react-dom&quot;: &quot;^16.5.2&quot;,
  &quot;phaser&quot;: &quot;^3.55.2&quot;,
  &quot;@ion-phaser/react&quot;: &quot;^1.3.0&quot;,
  </code></pre>