Skip to content

Page with getStaticProps has undefined props with Link clicks & pages router after Next.js 15.4.0 #956

@jschuur

Description

@jschuur

I've noticed that deploys via SST to AWS getStaticProps data is undefined, when following a <Link>

With a stock Next.js app using the pages router, if I follow a link via <Link href='/test'>Test</Link> to this page, the data is undefined:

// src/pages/test/index.tsx
export default function Test({ data }: { data: any }) {
  console.log('Text component rendered');

  if (!data) {
    return <div>No data</div>;
  }

  return (
    <div>
      <h1>Test</h1>
      <p>Data: {JSON.stringify(data)}</p>
    </div>
  );
}

export const getStaticProps = async () => {
  const res = await fetch('https://jsonplaceholder.typicode.com/posts/1');
  const data = await res.json();

  return {
    props: {
      data,
    },
  };
};

If I visit /test directly, I get data. This is only an issue on a deployed build and the pages router.

There was a Discord comment that this was fixed in OpenNext 3.5.0, but more recent versions of Next.js seem to break it again.

I get back undefined for data from Next 15.4.1 onwards with the current SST (3.17.10), which uses OpenNext 3.3.6. Works with 15.4.0. (15.4.1 release notes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions