# Zustand + Immer **Published by:** [Suyi](https://paragraph.com/@suyi-cn/) **Published on:** 2022-11-26 **URL:** https://paragraph.com/@suyi-cn/zustand-immer ## Content how to use zustand with immer ?Codeimport create from 'zustand'; import { produce } from 'immer'; interface AuthState { user?: { id: number; address: string; name?: string; email?: string; avatar?: string; token?: string; roles?: string[]; }; updateAuth: (data: AuthState) => void; resetAuth: () => void; } export const useUser = create<AuthState>((set, get) => ({ updateAuth: (data: AuthState) => { set( produce((draft: AuthState) => { draft.user = data.user; }) ); }, resetAuth: async () => { set( produce((draft: AuthState) => { draft.user = undefined; }) ); }, })); export default useUser; ## Publication Information - [Suyi](https://paragraph.com/@suyi-cn/): Publication homepage - [All Posts](https://paragraph.com/@suyi-cn/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@suyi-cn): Subscribe to updates