I have a NEXTJS 13 with Pages directory project. I want to request to our graphql server in every route change. And want to make it from server. But can i do it ? And even if I do it can I put this datas to my Redux store ? Thanks for responses!
I have a NEXTJS 13 with Pages directory project. I want to request to our graphql server in every route change. And want to make it from server. But can i do it ? And even if I do it can I put this datas to my Redux store ? Thanks for responses!
2
Answers
I suggest using the "router.events" of NextJS since there are plenty of router change events for you to choose. Their document can be found here and it is pretty straight forward. Server calls and redux interactions should be made easily inside the useEffect function.
Middleware is run upon every request and could be used to implement additional logic to call a GraphQL server.