Search code examples
reactjsfrontendclient-sidefile-structure

Client side rendering file structures


If I were to build a client side render site that has a user page and a admin page using React, does it make sense to have two separate HTMLs with separate bundle.js or I should just have one HTML with one bundle.js and have my script render the two pages/components conditionally? Why is one way better than the other way?


Solution

  • Two bundles:

    • If your admin site is independent of the client site and does not share views
    • If secret information is stored on the admin site

    One bundle:

    • If the sites share a lot of code or are virtually the same
    • If secret data is only loaded in to the site based on authenticated requests.

    Which is better depends on your needs. One thing to remember is that your site can be viewed through the dev console or other tools, so secret data needs to be sent only if the user is authenticated. It's up to your needs whether that means two sites or authenticated requests for data.