ReactJS - Adding reactjs in existing website

1 Create ReactJS app

Create any react app as usual you do. There is nothing special you need to configure to use the react app code in existing website.

2 Add the .env file at the root of this application

This file would contain some configuration values that will be used by build tool.

3 Add the INLINE_RUNTIME_CHUNK=false in .env file

This configuration would allow to create separate packaged code of entire react app at one place.

4 Run the build with npm run build.

5 It will generate static files in build/static path

6 Add these files in existing application

7 Add the container div with the id root

8 Run that page. You should see the react output in the div of your existing page in the div which has the id root.

Tags