2024-01-18
2087
#nextjs#redux
Mohammad Faisal
124532
Jan 18, 2024 â‹… 7 min read

How to use Redux in Next.js

Mohammad Faisal I am a full-stack software engineer working with the MERN stack. Also, I am a blogger in my free time and love to write about various technical topics.

Recent posts:

Building a Full-Featured Laravel Admin Dashboard with Filament

Building a full-featured Laravel admin dashboard with Filament

Build scalable admin dashboards with Filament and Laravel using Form Builder, Notifications, and Actions for clean, interactive panels.

Kayode Adeniyi
Dec 20, 2024 â‹… 5 min read
Working With URLs In JavaScript

Working with URLs in JavaScript

Break down the parts of a URL and explore APIs for working with them in JavaScript, parsing them, building query strings, checking their validity, etc.

Joe Attardi
Dec 19, 2024 â‹… 6 min read
Lazy Loading Vs. Eager Loading

Lazy loading vs. Eager loading

In this guide, explore lazy loading and error loading as two techniques for fetching data in React apps.

Njong Emy
Dec 18, 2024 â‹… 5 min read
Deno logo over an orange background

How to migrate your Node.js app to Deno 2.0

Deno is a popular JavaScript runtime, and it recently launched version 2.0 with several new features, bug fixes, and improvements […]

Yashodhan Joshi
Dec 17, 2024 â‹… 7 min read
View all posts

14 Replies to "How to use Redux in Next.js"

  1. I really like this tutorial and I am very grateful for it. But I have one question. I have a lot of pages, how can I maintain a state on every page? In your example you are using SSR, but do I need to invoke it on every page? It would be perfect to use it on layout component or something. Do you have any idea how to do it?

  2. What am I missing? I followed your article carefully and the state does not persist in the browser. I’ using the latest version of Chrome. I even downloaded your repo, added the node_modules, but even your own repo does not retain the state. I checked my code against your repo code also. What am I missing?

  3. It took me a while to figure out, but it looks like extraReducers should be moved outside of the reducers object in the authSlice.ts file

  4. Thank you for this great tutorial. That helped already. But one question please. Do we need the extraReducer with the Hydrate type in every single Slice?

  5. I’ve downloaded and ran the sample in production mode (npm run build; npm run start;), but when I examine initial Html served by the server – it only has “Loading”, unless I remove Persist Gate wrapper. Store state is passed from backend, but it’s not Hydrated in HTML. This kills SEO, which is one of the major reasons to use Next.JS. Am I missing something?

  6. Please note, that this article describes using redux with Page Router of Next 13. Next 13 also introduced App Router that integrate React Server Components, but works very differently and using Redux with it is not this straightforward.

Leave a Reply