I'm using Express framework on NodeJS (hosted by Heroku) to create my web site. I'm also using the React framework to create my ponents.
I have several HTML files with div
s inside and React ponents which can be rendered in those div
s.
When a user chooses a route (e.g. /movies
) I want to be able to associate one HTML file with a ponent and return it back to the user. I already looked for a solution, but all of them talk about server-side rendering and sending back HTML files.
Is there another solution?
I'm using Express framework on NodeJS (hosted by Heroku) to create my web site. I'm also using the React framework to create my ponents.
I have several HTML files with div
s inside and React ponents which can be rendered in those div
s.
When a user chooses a route (e.g. /movies
) I want to be able to associate one HTML file with a ponent and return it back to the user. I already looked for a solution, but all of them talk about server-side rendering and sending back HTML files.
Is there another solution?
Share Improve this question edited Sep 18, 2017 at 10:40 moopet 6,1851 gold badge30 silver badges37 bronze badges asked Feb 23, 2015 at 6:29 ArianArian 7,74924 gold badges107 silver badges190 bronze badges 1- Would you be able to give more details why you need more html files? Usually if you don't want to do server-side routing one HTML file serving as a container is enough, all the other views can be rendered straight from the Javascript – Arek Flinik Commented Mar 29, 2015 at 15:20
2 Answers
Reset to default 8Check out react router you don't have to use server side rendering, you just need to give a react ponent that you want to return when a route is requested.
The standard way to do this now is to build a Single-Page applications and redirect all requests to /
, and the front end routing will handle the required page to load.