DEV Community

Shubham Kumar
Shubham Kumar

Posted on

Is this the correct way to use useSWR with getServerSideProps?

This is the code sandbox example of how I'm using SWR with getServerSideProps: https://codesandbox.io/s/useswr-with-getserversideprops-nextjs-9u1gp?file=/containers/PostContainer/index.js

github repo link
What I want to achieve is on the post/[post] page the meta tags will be dynamic coming from the backend & will be users specific that's why I'm using getServerSideProps instead of getStaticProps, the above code is working fine but when I see the terminal on clicking a post it's calling the API 3 times & when I again click the same post API is being called 2 times is this normal behaviour?

Top comments (0)