Next.js getInitialProps context query is empty


I’m following this basic tutorial about Next.js.

They provide this code:

 Post.getInitialProps = async function(context) {
  const { id } = context.query;
  const res = await fetch(`${id}`);
  const show = await res.json();

  console.log(`Fetched show: ${}`);

  return { show };

which I have copy-pasted. However context.query is an empty object, so, my api call is failing.
Here’s the code from wehre I’m redirecting to that dynamic page (pages/p/[id].js)

<h1>Batman TV Shows</h1>
  { => (
    <li key={}>
      <Link href="/p/[id]" as={`/p/${}`}>


is this a bug, or am I missing something?


Ok, the answer is to update from v8.0.4 to v9.0.1 or newer. The tutorial here clearly states it

Leave a Reply

Your email address will not be published. Required fields are marked *