I am building an e-commerce application with Next.js and I need to manage global state for features like cart, user authentication, and product listings.
I have experience with both Redux Toolkit and Zustand but I am unsure which one is the better choice for a production-level app.
With Redux Toolkit I created a cartSlice using createSlice and configured the store like this:
const cartSlice = createSlice({
name: "cart",
initialState: { cartItems: [] },
reducers: {
addToCart: (state, action) => {
state.cartItems.push(action.payload);
},
},
});
With Zustand I created a store directly like this:
const useStore = create((set) => ({
cartItems: [],
addToCart: (item) =>
set((state) => ({ cartItems: [...state.cartItems, item] })),
}));
Both work fine for basic use cases but I have some concerns:
1. Which one scales better for large applications?
2. Which one has better TypeScript support?
3. Is Redux Toolkit overkill for a mid-size Next.js project?
4. Does Zustand have any limitations for complex state logic?
I would love to hear from developers who have used both in production and what their experience has been.