2
scout
50d

Hi react developers. Noob question, I am making a new (my first) react+redux toolkit+axios website…
So umm, what folder structure is best, and where does the user authentication part , the web services go?
Currently I have
-src
-pages
-index.js
-app.js
-about
-index.js
-stores
-common

Comments
  • 0
    API layer and backend come separately from this bundle. You are using frontend framework/boilerplate, right?
  • 0
    Yes front end

    As web services from some other external rest api, so will call them using axios
  • 1
    @scout If you wanna maintain them in a one pack, sure, just create `api`/`services` directory and put your services there. The question is how you're gonna run them - as separate processes or simultaneously. Another option is to maintain backend in completely separate place.
  • 0
    @scout I remember trying to find an automagical mapping between backend and frontend (no duplicating routes and API endpoints). I'm still in search of such convenience. And yet, some things just seem right in place when they are not contained in monorepository.
  • 0
    @vintprox by backend u mean the network calls right ?
  • 1
    @scout by backend I mean *processing* requests and all that's behind the wall.
  • 0
    Haven't tried redux toolkit query yet. Shouldn't you just use default and put slices and network queries under individual component folders? You also want to use Storybook and separate pure component from component that uses global states and network calls.

    @acemarke should have a bunch of related tutorials
  • 0
    @scout Before you mention SSR: calls are still made on frontend side. It's just that all initial requests for a full page render are performed beforehand. It's not a backend, the one which handles every checkout operation or updates user profile at demand. During SSR, you may need to fetch some data from the database, so you do calls to your backend through axios.

    So, with this in mind, the frontend is one hell of a fat ass glorified in the end. You team will notice it's much better to separate backend in this case. Look for a backend framework then.
Add Comment