Reputation: 23
According to Next.js, to render a dynamic path you need both getStaticPaths()
and getStaticProps()
the problem with this for me is, the data of the page is being cached. I'm using Contentful for my page data, but when I make an update in my post the update doesn't make it to the page. I have to re-compile and push to my production in order for the change to take place.
However, for non-dynamic routes I can use getServerSideProps()
and it works no problem.
I know with SWR you can render client-side, but with updated data.
Is there a way to render the Contentful data in a dynamic route during run-time with SWR rather than using Contentful's client.getEntry
?
Thanks!
Upvotes: 0
Views: 2161
Reputation:
You only need getStaticPaths
and getStaticProps
for dynamic routes if you want them statically generated at build-time (SSG). You can use getServerSideProps
instead on your dynamic routes if you want the data fetched at runtime - there is no issue with that, especially since you are already doing that for other pages.
See this section of the documentation that mentions using dynamic routes with getServerSideProps
.
Upvotes: 1