Registry / database / redux-orm

redux-orm

JSON →
library0.16.2jsnpmunverified

Redux-ORM simplifies managing normalized relational data in Redux stores by providing a declarative schema layer. Current stable version 0.16.2 is maintained with low release cadence. Key differentiators: it brings ORM concepts (models, fields, sessions) to Redux, enabling querying and updates without manual normalization/down-normalization. Unlike manual normalization, it reduces boilerplate and prevents inconsistencies, but requires understanding of relational modeling.

npm install redux-orm
INSTALL
IMPORT
SIG · REDUX-ORM
R
redux-orm
databasejavascriptv0.16.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ORM
import { ORM } from 'redux-orm'
import ORM from 'redux-orm'
ORM is a named export in ESM environments
Model
import { Model } from 'redux-orm'
const { Model } = require('redux-orm')
ESM-only since v0.16; use named import
many
import { many } from 'redux-orm'
const many = require('redux-orm').many
For defining many-to-many fields

Defines Author and Book models with a foreign key, creates a Redux store with the ORM reducer, and dispatches an action to insert a book.

import { ORM, Model, many, fk } from 'redux-orm'; import { createStore, combineReducers } from 'redux'; class Author extends Model { static modelName = 'Author'; } Author.fields = { id: 'number', name: 'string', }; class Book extends Model { static modelName = 'Book'; } Book.fields = { id: 'number', title: 'string', author: fk('Author', 'books'), }; const orm = new ORM(); orm.register(Author, Book); const reducer = orm.reducer(); const rootReducer = combineReducers({ orm: reducer }); const store = createStore(rootReducer); store.dispatch(orm.create('Book', { id: 1, title: 'War and Peace', author: 1 })); console.log(store.getState().orm.Book.all().toRefArray());
Debug
Known issues
breakingIn version 0.16, the library was rewritten to be ESM-only; CJS require() will break.
fix
Use import syntax; switch to Node >=12 with 'type': 'module' or use dynamic import.
affects: >=0.16
deprecatedThe 'Model' class static method 'fields' as an object literal is deprecated; use instance field 'fields' with arrow functions for dynamic fields.
fix
Use static get fields() { return { ... }; } or define on prototype.
affects: >=0.14
gotchaRedux-ORM does not handle nested commits automatically; calling session.create() returns a model instance that may not be synced until the reducer processes the action.
fix
Always dispatch actions via orm.create() or use the session object within a reducer.
affects: >=0.0.0
gotchaMigrations are not built-in; schema changes require manual migration logic or resetting state.
fix
Consider using redux-orm-props or handle schema evolution manually.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'redux-orm'
Missing dependency or wrong import path.
fix
Install: npm install redux-orm and ensure import path is 'redux-orm' (not './redux-orm').
orm.reducer is not a function
Attempting to call orm.reducer on a class instead of an instance.
fix
Instantiate ORM: const orm = new ORM(); then use orm.reducer().
TypeError: Class constructor Model cannot be invoked without 'new'
Using Model as a function without 'new' or importing incorrectly.
fix
Use import { Model } from 'redux-orm' and extend it: class Book extends Model { ... }.
Upgrade
Version history
0.16.2latest on npm
Audit
Dependencies
reduxrequireddesigned to integrate with Redux store
Agent activity
3 hits · last 30 days
node
2
Meta
1
Resources
redux-orm — npm install redux-orm · libregistry