Search code examples
node.jsreactjswebfrontendbackend

Does the client browser still communicate with my front end React server after the initial load?


The front end of my APP is built using React. The back end is built using Node.

When a user visits the URL where my front end React APP is hosted, the React server will send the APP to the user's browser.

After this point, does the user's browser still communicate with the React Server? Or will it just send its requests to the back end as programmed?

EDIT:

I use axios. I tested it by shutting my front end server after serving the app to the browser. The browser was able to make any axios request to the backend.


Solution

  • Your clients may send multiple requests to your front-end application server. Obviously, apart from the first ones when the user loads the page from the URL, for example, they can navigate in your app and then load images or static media, unless you're using a CDN or a different host for these files: They will be fetched from your front-end application server.

    Also, your React application might be using React.Lazy that loads modules dynamically, then you would fetch chunks every time the user loads the part of the page that contains these components.

    Or your styles may load images or fonts, which will be fetched when loading the components that defined them.

    One other case is when the user actually reloads the page, as you can't control them.

    So yes, and no. Your client MAY send other requests to your front-end server. Or it may not if you intentionally designed your app to prefetch and preload and/or cache everything when you load it in the first time.


    At the same time, your application communicate your API (Node.js backend application) by sending the requests as you programmed it (with fetch, Axios, etc)