Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Is it better to send normalized or denormalized API response back for React+Redux applications

I'm writing a react-redux application. At the beginning it calls a single endpoint, which returns a good amount of data as a heavily nested JSON. I then normalize it and put it into my redux-orm schema.
To me it seems silly to create the nested data on the backend just to loop through the nested data on the frontend in order to normalize it, considering it's coming from a normalized PostgreSQL database.

Database = Normalized --> 
API = Denormalized --> 
Frontend = Normalized

Is it best practice to just send back a normalized API response?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

I'm not sure there is a "good" way to do so. If you have to deal with an existing API, then deal with it, and use proxy/parsers in your frontend code to map your backend payload into your redux-orm store, and on the other side too.

I won't pretend here to give an answer, but rather a feedback, after nearly a year of production of our React/Redux/Redux-orm application Wisembly Jam.

When we started from scratch, we chose to use the JsonAPI spec for our API. We liked that as it exposed objects and relations in a way that fitted well with our PostgreSQL scheme, and also our redux-orm one.

That way, no model relation nesting needed both way, only plain objects handled in data field, included relations in included field. It appeared to work very nicely together.

You might inspect our application Network tab to look into our api payload responses, and also our redux-orm store (using Redux Chrome extension).

Hope that helped a bit, despite my english and not being properly an answer :)

over 4 years ago · Santiago Trujillo Report

0

It would help; as you said, it's recommended to have normalized data in state: https://redux.js.org/faq/organizing-state#how-do-i-organize-nested-or-duplicate-data-in-my-state

If you still want to send nested data from the API, e.g. to only send what is needed or if it's an existing API, you can normalize on the client side before adding the data to the store. For example with this library: https://redux.js.org/faq/organizing-state#how-do-i-organize-nested-or-duplicate-data-in-my-state

over 4 years ago · Santiago Trujillo Report

0

I don't understand why anyone would normalize on the front. The whole reason I do normalization is to get rid of repetition. Instead of sending the same nested data, say user object, multiple times, i nest the user id, and in a separate property called "users", I would send all the users needed with their ids as keys for quick and easy access as follows:

"users": {
    "1": { "id": "1", "name": "user_name", ...rest_of_user_details},
    ...
}

After all, it's easier for the front to deal with non-normalized data. It takes less code to just list data with nested objects as-is rather than access those objects inside other properties using the object ids.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!