React + Redux with a rest api?

17,417

Solution 1

Redux itself has nothing to do with API communication, it's the library for client-side state management. You can use whatever approach for firing and handling requests, most common are using custom api-connecting middleware, returning functions, which fire requests, from action-creators and using them with thunk-middleware or using alternative approaches like rx-bridges or sagas.

Solution 2

Start with: https://egghead.io/series/getting-started-with-redux

Reffer to: What is best practice to communicate between React components and services?

Redux by design forces to build SPA application.

Solution 3

First, see examples from redux docs, "Real World" is most useful: https://github.com/reactjs/redux/tree/master/examples/real-world

Then, you can research useful utils like redux-promise-middleware.

Finally, you can try to use some complex utils for connect your redux-app with API. redux-rest-adapter is one of them.

Share:
17,417

Related videos on Youtube

Dave
Author by

Dave

Updated on September 15, 2022

Comments

  • Dave
    Dave over 1 year

    I have a simple CRUD app I am building in node, and have finished creating the rest API in Express. I am now looking to add front end functionality and wish to use react + redux as a learning exercise. It seems however all of the tutorials around this access the data directly using Redux, rather than interfacing with an internal API.

    My question is, is that the correct way to build a SPA with redux? I was under the impression it was best to separate the front end from the backend so that I could, for example, build an iPhone app and not have to rebuild the backend.

    Thanks in advance.

  • Dave
    Dave about 8 years
    That clears things up - thank you ever so much for the reply, and the suggested middleware.