Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Redux Toolkit · Module

adapter.addMany

createEntityAdapter.addMany inserts multiple entities into normalized Redux state, accepting either an array or an ID-keyed record. It skips entities whose IDs already exist.

How it works

Call an entity adapter's addMany helper with the current entity state and either an array of entities or an ID-keyed entity object. It inserts only entities whose IDs are not already present; use it as a case reducer or as a mutating helper inside a Redux Toolkit reducer.

Syntax

adapter.addMany(state, entities)

Parameters

NameTypeDescription
stateEntityState<T, Id>The adapter-managed entity state, commonly a draft state inside createSlice or createReducer.
entitiesT[] | Record<EntityId, T>Entities to insert, supplied as an array or as a record keyed by entity ID.

Returns

An updated entity state when used as a standalone adapter helper; when used as a case reducer, it updates the reducer state through Immer.

Key points

  • addMany is intended for inserting several new entities into an adapter-managed collection.
  • Its entity input supports either a list or an ID-keyed record.
  • Insertion is conditional on ID absence, preserving existing records.
  • Use the generated helper directly as a case reducer in Redux Toolkit reducer APIs.
  • Inside an Immer-backed reducer, call addMany with the draft state and payload.

Common mistakes

  • Existing IDs are not replaced; use upsertMany when incoming entities should also update matching records.
  • The second argument can be an array or an already normalized ID-keyed object, not just an array.

Example: Add multiple entities

import { createEntityAdapter, createSlice } from '@reduxjs/toolkit'

type Book = { id: string; title: string }

const booksAdapter = createEntityAdapter<Book>()
const booksSlice = createSlice({
  name: 'books',
  initialState: booksAdapter.getInitialState(),
  reducers: {
    booksReceived(state, action: { payload: Book[] }) {
      booksAdapter.addMany(state, action.payload)
    },
  },
})

booksSlice.actions.booksReceived({
  type: 'books/received',
  payload: [{ id: '1', title: 'Redux' }],
})

The adapter helper inserts each previously absent book into the normalized slice state.

When to use it

Merge new API items

Bulk-loading records returned by an API into a normalized slice without replacing existing records.

Populate a slice

Calling the helper from a createSlice case reducer to add a payload of entities.

Insert pre-normalized data

Passing data that has already been converted to a Record<EntityId, T> without another conversion step.

Interview questions

QWhat does addMany do?

addMany is a generated entity-adapter reducer for bulk insertion into normalized state. It accepts the entity state plus an array of entities or a Record keyed by entity ID, and skips entities already present.

Follow-up: How would you update existing records during the same operation? Use upsertMany, which adds missing entities and updates existing ones.

QWhere can addMany be used?

The helper updates the adapter-managed normalized structure, which stores IDs in an array and entities in a lookup object. It can be supplied as a case reducer or called inside a createSlice reducer.

Follow-up: What determines the key used for each entity? The adapter's selectId configuration determines how an entity ID is obtained when the default id property is not suitable.

QWhat inputs does addMany accept?

Pass the current state as the first argument and the collection as the second: adapter.addMany(state, entities). The collection may already be keyed by IDs, so normalized API output can be passed directly.

Follow-up: What if the incoming data contains nested objects? Normalize or transform that data before inserting it; the adapter manages entity collections rather than recursively normalizing nested values.

  • createEntityAdapter
  • addOne
  • upsertMany
  • setAll
  • removeMany
  • getInitialState

Source: createEntityAdapter. Checked 2026-10-15.