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?
Asked
Active
Viewed 66 times
-1

yume
- 11
- 2
1 Answers
0
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.

Sydney Y
- 2,912
- 3
- 9
- 15
-
If I use a templating engine like mustache and insert the corresponding bundle depending on requests, would it result in two separate html files or one? (sorry im new with using this site, if this should be a separate post, please lemme know) Thank you in advance. – yume Feb 09 '20 at 02:21
-
You should open another question just to get more input from other people, but let's you and I clarify what you're asking: are you running this template engine once to prepare for deployment, or are you using middleware on your server to render on-the-fly per request? – Sydney Y Feb 09 '20 at 04:53