354 questions
Tooling
3
votes
4
replies
202
views
Redux Toolkit vs Zustand: which is better for global state management in a Next.js e-commerce app?
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 ...
Best practices
0
votes
3
replies
448
views
Source of truth: state (zustand) vs url (react router)
I've got a question!
I have an app where I use Zustand for my state management. For example I have states for the currentProject, current dataset and current view which decides what it shown.
I now ...
Best practices
0
votes
2
replies
270
views
Best way to initialize data in next js app router with zustand
I’m building an e-commerce type website in Next.js where there are multiple sections of stores. Each store card has a heart icon to mark it as a favourite.
The same store can appear in:
multiple ...
Score of 1
1 answer
104 views
Zustand persist doesn't execute in testing
I am doing unit testing for my project.
This is the code I want to test:
import { create } from "zustand";
import { persist } from "zustand/middleware";
interface LanguageState {
...
Score of 1
1 answer
300 views
How to make server actions work seamlessly with Zustand state updates in client components?
I was working on Next.js 15 (App Router) and trying to integrate Server Actions with Zustand for client-side state management.
// store.ts
import { create } from 'zustand';
export const ...
Score of 2
2 answers
118 views
Why won't my React app render a simple "Loading" text which is connected to a state?
My HomePage.jsx looks like this:
import {
Box,
Container,
SimpleGrid,
Text,
useColorModeValue,
VStack,
} from "@chakra-ui/react";
import { useEffect, useState } from "react&...
Score of 0
0 answers
53 views
useEffect not triggering on web with Expo Router + Zustand (works on Android)
I’m using React Native with Expo Router and Zustand to handle authentication-based redirection. The logic works correctly on Android, but on Web the useEffect is not triggered, which prevents the user ...
Score of 2
0 answers
60 views
Zustand not resetting state in between tests
beforeEach(() => {
useStore.setState(useStore.getInitialState(), true)
})
it("does something", () => {
renderComponent()
expect(screen.getByLabelText(/Event Type/i))....
Score of 2
1 answer
364 views
Zustand persist in Next.js resets state after navigation and causes hydration mismatch
I'm building a Next.js 14 app that uses Zustand with the persist middleware to store authentication tokens and user info.
My goal is to have the tokens persist across page navigations and browser ...
Score of 0
1 answer
733 views
Simple zustand store with persist do not get storage in local storage
I have created the following Zustand store. For now it is fairly simple, and I have planned to update its functionality afterwards.
import { create } from 'zustand';
import { persist } from 'zustand/...
Score of 1
1 answer
55 views
How to make the audio toggle work reliably?
I'm using Next.js with TypeScript and Zustand for state. I have a music toggle button in my hero section that should play/pause background music.
The button UI updates correctly, but the audio doesn't ...
Score of 0
0 answers
250 views
Zustand custom createStore with persist, immer, and devtools breaks action typing for set function
I'm trying to build a reusable createStore utility for Zustand that automatically applies devtools middleware, and optionally wraps with persist and immer. Here's a simplified version of my code:
...
Score of 0
0 answers
135 views
How to hook several state fields in React Component
useAppStore is a Zustand Store.
I made 3 assumptions based on my understand of React hooks (Please correct me if any of them is wrong):
const MessageList: React.FC<MessageListProps> = ({ ...
Score of 1
1 answer
257 views
react zustand state persistance behavior not the same between browser and private browser
I am trying to persist state management to session storage. Currently I can save the state on the browser and state is shared on all tabs (new and old) for as long as any one tab is open.
However when ...
Score of 1
0 answers
377 views
Zustand store shared via Module Federation only provides initial value in remote app
I'm building a micro-frontend architecture using Webpack Module Federation. I have a host app and a remote app (cart), and I'm trying to share a global Zustand store (themeStore) from the host to the ...