<p>I am deploying a NextJS app in various K8 environments, each passing it's own variables. I can pass them in and get them with <code>getServerSideProps()</code>, but as this function works on page components (or at least that's what the docs say), I have to add them in every single page through which my users can &quot;enter&quot; the application. This becomes error prone.</p>
<p>What I would like, ideally, is to be able to have a <code>getServerSideProps()</code> on the <code>_app.tsx</code>, which I cannot.</p>
<p>What is the best alternative?</p>

Mike M
<p><a href="https://nextjs.org/docs/pages/api-reference/functions/get-initial-props" rel="nofollow noreferrer"><code>getInitialProps</code></a> seems what you want.</p>
<pre class="lang-js prettyprint-override"><code>App.getInitialProps = async ({  ctx }: AppContext) =&gt; {
  const something = await getData();

  return { pageProps: { something } }
}

export default App;
</code></pre>
