Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. React Hooks
  3. use-immer

use-immer

MITTypeScript

A React hook that provides immutable state updates using Immer's mutable draft syntax.

GitHubGitHub
4.5k stars102 forks0 contributors

What is use-immer?

use-immer is a React hook library that integrates Immer to simplify immutable state updates in React components. It allows developers to write state updates using mutable syntax on a draft object, which Immer automatically converts into the next immutable state. This solves the problem of verbose and error-prone immutable update patterns when managing complex state in React.

Target Audience

React developers who need to manage complex or nested state immutably and want a more intuitive syntax than spread operators or immutable libraries.

Value Proposition

Developers choose use-immer because it reduces boilerplate and potential bugs in state updates by allowing mutable-like code while guaranteeing immutability. It seamlessly replaces `useState` or `useReducer` with Immer's producer functions, making state management more readable and maintainable.

Overview

Use immer to drive state with a React hooks

Use Cases

Best For

  • Updating deeply nested state objects in React without verbose spread operators
  • Simplifying reducer logic in React applications with mutable draft syntax
  • Migrating from mutable state patterns to immutable updates with minimal refactoring
  • Managing complex form state or UI state with intuitive update functions
  • Reducing bugs in state updates caused by manual immutable operations
  • Integrating Immer's capabilities directly into React hooks for seamless development

Not Ideal For

  • Projects with minimal, flat state where immutable updates are straightforward without Immer's abstraction
  • Teams already using Redux Toolkit or similar libraries with built-in Immer integration
  • Performance-critical applications where Immer's draft system overhead could impact frequent updates

Pros & Cons

Pros

Intuitive Mutable Syntax

Allows writing state updates as if mutating objects directly, reducing boilerplate compared to spread operators, as shown in the README examples with draft mutations.

Seamless Hook Integration

Mirrors the API of useState and useReducer, making adoption easy for React developers without learning new patterns, evidenced by the similar function signatures in the API section.

Powered by Reliable Immer

Leverages the established Immer library for robust immutable updates, ensuring state consistency and reducing bugs, as stated in the project description.

Simplifies Complex State

Ideal for managing deeply nested state objects, making updates more readable and maintainable, highlighted in the key features for reducing errors.

Cons

Performance Overhead

Immer's draft system introduces runtime costs for creating and managing drafts, which can be noticeable in apps with high-frequency state updates or large state trees.

Extra Dependency

Adds immer as a dependency, increasing bundle size and tying the project to Immer's maintenance, updates, and potential breaking changes.

Overkill for Simple Cases

For trivial state management, use-immer adds unnecessary complexity, as acknowledged in the README where it mentions Immer is overkill for basic examples.

Frequently Asked Questions

Quick Stats

Stars4,514
Forks102
Contributors0
Open Issues9
Last commit1 year ago
CreatedSince 2018

Tags

#immutability#frontend#javascript#react-hooks#react#state-management

Built With

R
React

Included in

React Hooks1.2k
Auto-fetched 1 day ago

Related Projects

react-hook-formreact-hook-form

📋 React Hooks for form state management and validation (Web + React Native)

Stars44,670
Forks2,389
Last commit1 day ago
react-usereact-use

React Hooks — 👍

Stars43,973
Forks3,273
Last commit3 months ago
The PlatformThe Platform

Web. Components. 😂

Stars4,386
Forks106
Last commit3 years ago
react-firebase-hooksreact-firebase-hooks

React Hooks for Firebase.

Stars3,639
Forks304
Last commit2 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub