title: Next.JS single page application?
body: <p>I am trying to make a single-page application in NextJS, but I am starting to think this is not possible. Can anyone show me how?</p>
  
  <p>My first attempt was to use a Hash Router:</p>
  
  <pre><code>&lt;HashRouter&gt;
                  &lt;div&gt;
                      &lt;NavLink to="/"&gt;Home&lt;/NavLink&gt;
                      &amp;nbsp;&amp;nbsp;
                      &lt;NavLink to="/purchaseComplete"&gt;Purchase Complete&lt;/NavLink&gt;
                  &lt;/div&gt;    
                  &lt;div&gt;
                      &lt;Route exact path="/" Component={Default} /&gt;      
                      &lt;Route path="/purchaseComplete" Component={PurchaseComplete} /&gt;
                  &lt;/div&gt;
              &lt;/HashRouter&gt;
  </code></pre>
  
  <p>But in the browser I see "Invariant failed: Browser history needs a DOM"</p>
  
  <p>I then tried to use a StaticRouter:</p>
  
  <pre><code>&lt;StaticRouter location="/" context={staticContext}&gt;
                  &lt;div&gt;
                      &lt;NavLink to="/"&gt;Home&lt;/NavLink&gt;
                      &amp;nbsp;&amp;nbsp;
                      &lt;NavLink to="/purchaseComplete"&gt;Purchase Complete&lt;/NavLink&gt;
                  &lt;/div&gt;    
                  &lt;div&gt;
                      &lt;Switch&gt;
                          &lt;Route exact path="/" Component={Default} /&gt;              
                          &lt;Route path="/purchaseComplete" Component={PurchaseComplete} /&gt;
                      &lt;/Switch&gt;
                  &lt;/div&gt;
              &lt;/StaticRouter&gt;
  </code></pre>
  
  <p>This renders the two links, but nothing happens when you click them.</p>
  
  <p>In the NextJS tutorials, they talk about SPA's in the beginning, but then they only show you how to make apps with multiple pages.</p>
  
  <p>I am starting to think it's not possible to build an SPA in NextJS. Can anyone confirm this? Or can someone show me how to build an SPA in Next JS?</p>