
Use React in SharePoint Site
There are only a few ways we can use react in SharePoint. One is via the new SharePoint Framework, which enables full support for client-side development and open source tools. Another method of using React with SharePoint (which I choose), it simply uploads your build files to SharePoint library, reference to your app using content web part or using SharePoint page.
Steps to host your React application into the sharepoint
To use this example, clone this repo, install dependencies, and then start the gulp process with the following steps
- git clone https://github.com/SuriM92/instant-youtube.git
- cd instant-youtube
- npm install
- npm start
In order to deploy this app to SharePoint, make sure that you edit the package.json file, change the homepage setting to the path to your application.
- “homepage”: “/sites/mysite/SiteAssets/test/
Build react application to deploy it to sharepoint
- npm run build
Once the build process completes, then copy all files in the build folder to the SharePoint library(site assets/ site-library) change the index.html to index.aspx
Example – http://sharepointserver/sites/mysite/SiteAssets/test/index.aspx
Conclusion
This is a simple lightweight example of using React with SharePoint. You can do more feature with your application and make use of in memory routing for inner page routing.