<p dir="auto">In the meantime, using the above ideas here is what I came up with:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { withRouter } from 'next/router';

export const withPageRouter = Component =&gt; {
  return withRouter(({ router, ...props }) =&gt; {
    router.query = [
      ...new URLSearchParams((router.asPath || '').split(/\?/)[1]).entries()
    ].reduce((q, [k, v]) =&gt; Object.assign(q, { [k]: v }), {});

    return &lt;Component {...props} router={router} /&gt;;
  });
};
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">withRouter</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'next/router'</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-en">withPageRouter</span> <span class="pl-c1">=</span> <span class="pl-v">Component</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">return</span> <span class="pl-en">withRouter</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">{</span> router<span class="pl-kos">,</span> ...<span class="pl-s1">props</span> <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-s1">router</span><span class="pl-kos">.</span><span class="pl-c1">query</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span>
      ...<span class="pl-k">new</span> <span class="pl-v">URLSearchParams</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">router</span><span class="pl-kos">.</span><span class="pl-c1">asPath</span> <span class="pl-c1">||</span> <span class="pl-s">''</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">split</span><span class="pl-kos">(</span><span class="pl-pds"><span class="pl-c1">/</span><span class="pl-cce">\?</span><span class="pl-c1">/</span></span><span class="pl-kos">)</span><span class="pl-kos">[</span><span class="pl-c1">1</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">entries</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">reduce</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">q</span><span class="pl-kos">,</span> <span class="pl-kos">[</span><span class="pl-s1">k</span><span class="pl-kos">,</span> <span class="pl-s1">v</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">assign</span><span class="pl-kos">(</span><span class="pl-s1">q</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">k</span><span class="pl-kos">]</span>: <span class="pl-s1">v</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">return</span> <span class="pl-c1">&lt;</span><span class="pl-ent">Component</span> <span class="pl-kos">{</span>...<span class="pl-s1">props</span><span class="pl-kos">}</span> <span class="pl-c1">router</span><span class="pl-c1">=</span><span class="pl-kos">{</span><span class="pl-s1">router</span><span class="pl-kos">}</span> <span class="pl-c1">/</span><span class="pl-c1">&gt;</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><em>Originally posted by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/cansin/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/cansin">@cansin</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="342645355" data-permission-text="Title is private" data-url="https://github.com/vercel/next.js/issues/4804" data-hovercard-type="issue" data-hovercard-url="/vercel/next.js/issues/4804/hovercard?comment_id=541420735&amp;comment_type=issue_comment" href="https://github.com/vercel/next.js/issues/4804#issuecomment-541420735">#4804 (comment)</a></em></p>
<hr>
<p dir="auto">We should make sure (add a test) that client-side query strings are correctly merged into statically exported pages post-hydration (for a normal and dynamically routed 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?q=test">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ npm run test"><pre class="notranslate">$ npm run <span class="pl-c1">test</span></pre></div>
<p dir="auto">Should run testcases without mistakes</p>
<h2 dir="auto">Current Behavior</h2>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/5475069/38540314-25c3de5c-3cce-11e8-96f2-ac37c0ac4945.png"><img src="https://user-images.githubusercontent.com/5475069/38540314-25c3de5c-3cce-11e8-96f2-ac37c0ac4945.png" alt="image" style="max-width: 100%;"></a></p>
<h2 dir="auto">Steps to Reproduce (for bugs)</h2>
<ol dir="auto">
<li>download next.js canary</li>
<li><code class="notranslate">npm install</code></li>
<li><code class="notranslate">npm run test</code></li>
</ol>
<h2 dir="auto">Your Environment</h2>
<table role="table">
<thead>
<tr>
<th>Tech</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>next</td>
<td>canary</td>
</tr>
<tr>
<td>node</td>
<td>6.7.0</td>
</tr>
<tr>
<td>OS</td>
<td>Mac OS 10.12.6</td>
</tr>
<tr>
<td>tty</td>
<td>zsh</td>
</tr>
</tbody>
</table>