getinitialprops to a hoc in next js
const YourNewComponent = wrapperHoc(...) YourNewComponent.getInitialProps = async (ctx) => { const res = await fetch('https://api.github.com/repos/vercel/next.js') const json = await res.json() return { stars: json.stargazers_count } } export default YourNewComponent
Source: stackoverflow.com