githubEdit

normalizr

Install

Install from the NPM repository using yarn or npm:

yarn add normalizr
npm install normalizr

Motivation

Many APIs, public or not, return JSON data that has deeply nested objects. Using data in this kind of structure is often very difficultarrow-up-right for JavaScript applications, especially those using Fluxarrow-up-right or Reduxarrow-up-right.

Solution

Normalizr is a small, but powerful utility for taking JSON with a schema definition and returning nested entities with their IDs, gathered in dictionaries.

Documentation

Examples

Quick Start

Consider a typical blog post. The API response for a single post might look something like this:

We have two nested entity types within our article: users and comments. Using various schema, we can normalize all three entity types down:

Now, normalizedData will be:

Dependencies

None.

Credits

Normalizr was originally created by Dan Abramovarrow-up-right and inspired by a conversation with Jing Chenarrow-up-right. Since v3, it was completely rewritten and maintained by Paul Armstrongarrow-up-right. It has also received much help, enthusiasm, and contributions from community membersarrow-up-right.

Last updated