score:3

You can find out if it is currently executed on the server by checking for req attribute inside getInitialProps

Example page code

function Page({ isServer }) {
  return <div>Is this page on the server? - {isServer ? 'YES' : 'NO'}</div>;
}

Page.getInitialProps = async ({ req }) => {
  return { isServer: !!req };
};

export default Page;

Some info on official repo about isServercheck


Related Query

More Query from same tag