next-redux-wrapper icon indicating copy to clipboard operation
next-redux-wrapper copied to clipboard

NextJs 13 using app directory with redux

Open mlnima opened this issue 2 years ago • 8 comments

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 avatar Nov 21 '22 00:11 mlnima

@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.

DominicGBauer avatar Jan 06 '23 08:01 DominicGBauer

new app directory structure is not supported by this package. at least for now

ethyaan avatar Jan 24 '23 07:01 ethyaan

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.

mlnima avatar Jan 24 '23 07:01 mlnima

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.

kirill-konshin avatar Jan 24 '23 19:01 kirill-konshin

Any updates?

stigmat4j avatar May 16 '23 16:05 stigmat4j

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

mlnima avatar May 16 '23 16:05 mlnima

router must be imported from next/navigation instead of next/router.

Sean-Y-X avatar Jun 17 '23 10:06 Sean-Y-X

Hello there, Is any update for this thread? I also facing the same issue. currently, the NextJS 13 stable version.

marvin-min avatar Oct 21 '23 03:10 marvin-min