next-redux-wrapper
next-redux-wrapper copied to clipboard
NextJs 13 using app directory with redux
Is your feature request related to a problem? Please describe. it is possible to add redux but it won't initial on the server
Describe the solution you'd like my whole app uses redux for data fetching and rendering the HTML so it is fully serverside rendering but it can't work now
@mlnima this is mentioned here https://github.com/kirill-konshin/next-redux-wrapper/issues/494 but to summarise for the foreseeable future at least it doesn't look like this package will work with the new app
structure.
new app directory
structure is not supported by this package. at least for now
Thank you all, I think the problem is solved by not using the package, Like any other state management we need to use ('use client';) in order to use redux. It is too soon to move the entire project to the app directory since it's in beta.
So far there is no clear way to use Redux with Server Components...
First of all, components that use Redux needs a Provider
up in the tree in order to work, and Provider
is using Context
, which is not available on server (yet?).
With that said, I suggest to keep Redux as client component ("use client"
), and keep server-side state outside of Redux.
Any updates?
soon I will move the pages from pages to "app" directory on my existing project. To benefit the server component, we can only fetch the data inside the page file. how ever a few months ago I ran redux on pages in the "app" directory but without [next-redux-wrapper] and I had to add 'use client' at the top of redux files also the file you wanna add the provider
router
must be imported from next/navigation
instead of next/router
.
Hello there, Is any update for this thread? I also facing the same issue. currently, the NextJS 13 stable version.