Setup Redux(Saga)+ Nextjs, Error: Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware
Hello everyone,,,
Very long time i’am not writing and update on medium, so for the first writing on the 2022 i wanna share my experience when i must be setup redux on nextjs.
actually i’am not very expert on nextjs because I prefer to be use reactjs, I dont know why?? I think that’s because my project so much on reactjs. but if you read a documentation nextjs it’s so powerfull than react.
and maybe I will migrate my react project to nextjs :v,
and the second reason because nextjs is support for SEO or search enginee optimization. and react doesn’t have it.
that’s important to be use, because SEO can help others people search easily to find your website, but if your company dont need SEO yeah that’s no matter usingreact for your project. is optional.
back to issues.
A few days ago, I’ve to setup nextjs with redux and i have like a template or boilerplate for setup redux, so my code is like this:

and I getting issues like on below
note: for use createWrapper you must be install from next-redux-wrapper. and for the details and reason why I use it, because I not use provider for wrapper root components “setup redux on nextjs”

and for the fix it, I just create like this

I wrapper sagaMiddleware.run(sagas) inside makeStore function and I create variable store to wrap createStore and return store under sagaMiddleware.run(sagas)
I hope this help thank you