I have a website that will show dynamic data (Articles), i.e data that changes hourly.
I therefore have opted to use getServerSideProps() from NextJS.
export async function getServerSideProps() {
const url = process.env.NEXT_PUBLIC_API_URL
const articles = await fetch(url + 'article').then(res => res.json()).catch(err => console.error(err))
console.log("articles", articles);
return {
props: {
articles,
}
}
}
I could not use getStaticPaths() because the data changes so frequently, an hour after building the site and all the static paths would point to out-of-date articles, and all the new articles would not have any paths pointing to them. I also looked at ISR however this also wouldn't work as it relies on knowing the paths in advance.
My issue arises that because getServerSideProps() is completely dynamic, search engines do not see any of the dynamic pages (which is pretty much the entire site), and therefore I do not rank well.
Is there a way to use getServerSideProps() with some kind of caching, that will allow search engines to see the pages? If not, is there an alternative framework I can use that allows dynamic pages while retaining some SEO performance?