Can I migrate next 13 and redux?
Unanswered
Northeast Congo Lion posted this in #help-forum
Northeast Congo LionOP
now I am updating older project with next redux saga. I am using new app directory.
My main aim is implementing server components and metadata.
but we couldn't use Use State and Lifecycle Effects (useState(), useReducer(), useEffect(), etc) in server components.
how can I do to maintain the redux state of the older project to save effort?
Please provide directional guidance.
My main aim is implementing server components and metadata.
but we couldn't use Use State and Lifecycle Effects (useState(), useReducer(), useEffect(), etc) in server components.
how can I do to maintain the redux state of the older project to save effort?
Please provide directional guidance.
2 Replies
Yes, you can't use state in server components. Server components are not supposed to re-render.
Hence, for stateful applications, please use client components. You can pre-fetch data in server components, which also provides better SEO.
Next.js docs is really detailed, you should start reading:
- [Migrate to App Router](https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration)
- [Good practices for Server Components](https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns)
- [More about Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components)
- [New routing system](https://nextjs.org/docs/getting-started/project-structure)
To save effort, just stay in Pages Router. You aren't required to migrate away from Pages Router as of now. It is guaranteed that it won't be deprecated in ~2 incoming major updates.
Hence, for stateful applications, please use client components. You can pre-fetch data in server components, which also provides better SEO.
Next.js docs is really detailed, you should start reading:
- [Migrate to App Router](https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration)
- [Good practices for Server Components](https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns)
- [More about Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components)
- [New routing system](https://nextjs.org/docs/getting-started/project-structure)
To save effort, just stay in Pages Router. You aren't required to migrate away from Pages Router as of now. It is guaranteed that it won't be deprecated in ~2 incoming major updates.
Normally, you won't migrate the whole app at once but slowly migrate to it. (e.g. use App Router for new pages)