<p dir="auto">I have a project at the moment that uses nextjs embedded in an express server. I have a page called <code class="notranslate">event.js</code> and I route <code class="notranslate">/event/:eventId</code> to <code class="notranslate">/event?eventId={id}</code>.</p>
<p dir="auto">My issue now is that if the user goes to <code class="notranslate">/event</code> without specifying an ID my page component is rendered anyway.</p>
<p dir="auto">My suggestion is: Allow <code class="notranslate">getInitialProps</code> function to return <code class="notranslate">null</code> (or <code class="notranslate">false</code> or <code class="notranslate">404</code> or <code class="notranslate">new Error("")</code>), which will result in next intercepting this and rendering the 404 page.</p>


<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/zeit/next.js/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Current Setup</h2>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="expressApp.get('/event/:eventId', (req, res) =&gt; {
  const mapToUrl = '/event'
  const query = {
    ...req.query,
    eventId: req.params.eventId
  }
  nextApp.render(req, res, mapToUrl, query)
})

expressApp.get('*', nextHandler)"><pre class="notranslate"><span class="pl-s1">expressApp</span><span class="pl-kos">.</span><span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s">'/event/:eventId'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">req</span><span class="pl-kos">,</span> <span class="pl-s1">res</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">const</span> <span class="pl-s1">mapToUrl</span> <span class="pl-c1">=</span> <span class="pl-s">'/event'</span>
  <span class="pl-k">const</span> <span class="pl-s1">query</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    ...<span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-c1">query</span><span class="pl-kos">,</span>
    <span class="pl-c1">eventId</span>: <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-c1">params</span><span class="pl-kos">.</span><span class="pl-c1">eventId</span>
  <span class="pl-kos">}</span>
  <span class="pl-s1">nextApp</span><span class="pl-kos">.</span><span class="pl-en">render</span><span class="pl-kos">(</span><span class="pl-s1">req</span><span class="pl-kos">,</span> <span class="pl-s1">res</span><span class="pl-kos">,</span> <span class="pl-s1">mapToUrl</span><span class="pl-kos">,</span> <span class="pl-s1">query</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span>

<span class="pl-s1">expressApp</span><span class="pl-kos">.</span><span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s">'*'</span><span class="pl-kos">,</span> <span class="pl-s1">nextHandler</span><span class="pl-kos">)</span></pre></div>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/zeit/next.js/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>

<p dir="auto">Need to be able to update url without any navigation ie a <code class="notranslate">history.replaceState</code></p>

<p dir="auto">The docs say in <a href="https://github.com/zeit/next.js#imperatively">https://github.com/zeit/next.js#imperatively</a>:</p>
<blockquote>
<p dir="auto">Note: in order to programmatically change the route without triggering navigation and component-fetching, use props.url.push and props.url.replace within a component</p>
</blockquote>
<h2 dir="auto">Current Behavior</h2>


<p dir="auto">The call gives a deprecation warning and still triggers navigation</p>
<h2 dir="auto">Steps to Reproduce (for bugs)</h2>


<ol dir="auto">
<li>use props.url.replace within a component</li>
<li>notice that a navigation is triggered.</li>
<li></li>
<li></li>
</ol>
<h2 dir="auto">Context</h2>


<p dir="auto">I am trying to update the url without anything else changing. A way to do a history.replaceState in the next.js world. Calling history.replaceState steps outside the next.js router and then messes up<br>
back navigation. Using {shallow:true} with Router.replace still calls componentWillReceiveProps.</p>