0

Let's say I have a react application hosted at example.com. Now, I already have a very simple html/js website that I want to display at example.com/example. I can easily do this if I rewrite the website in react, but I don't want to do that because the html/js website is so simple and it would be unnecessary to be written in react.

Is there any way I can directly put and link this html/js website with the rest of my project?

Evan Hsueh
  • 139
  • 1
  • 2
  • 9
  • https://medium.com/@justintulk/serving-static-html-into-a-react-component-using-node-express-8cb9fc9194df this may help you, though serving static HTML pages using the react way really isn't that much overhead (and looks better), but there's nothing wrong with having node serve up a static dir – Sterling Archer Mar 25 '19 at 20:49
  • What is your back end for the react project? – Isaac Vidrine Mar 25 '19 at 20:51
  • React is just a JavaScript library, same as, let's say, jQuery. You can even have a different framework for each page (eg. index.html can be React, example.html can be vanilla JS, test.html can be Angular). You can even all of them on the same page. – XCS Mar 25 '19 at 21:02
  • This might help you for the same. https://stackoverflow.com/a/45936690/11253427 – Mogambo Mar 25 '19 at 21:15

1 Answers1

2

When you create React app with create-react-app you have the following filesystem structure:

my-app/
 README.md
 node_modules/
 package.json
 public/
   index.html
   custom-page.html <-- Create custom page
   favicon.ico
 src/
   App.css
   App.js
   App.test.js
   index.css
   index.js
   logo.svg

https://facebook.github.io/create-react-app/docs/folder-structure

So, you can just create any static pages in /public directory and reference them. All the resources in /public directory will be available in the root of your website.

For example, custom-page.html will be accessible by http://localhost:3000/custom-page.html.

Vlad DX
  • 4,200
  • 19
  • 28