How to deploy React Application,

0


If you want to host react application under a Live server with cPanel, AWS, AZURE, or any Cloud Server then the following step will be implemented.

If you have already a server then you can prefer it otherwise you can go under the free hosting site and create an account it will provide a free hosting server.

LINK:- https://www.freehosting.com/

1)   Create React Project Under Local Machine with this command

npx create-react-app  reactfirst

2)  go into package.json file and add following code

"homepage": "domainname/reactfirst",

3) create .htaccess and write a subbfolder name

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /reactfirst/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /reactfirst/index.html [L]
</IfModule>

4) Create a Build

npm run build

5) create a ZIP of this build and upload into the server

go into Cpanel and create folder reactfirst and upload all files

domainname/foldername

6) Note if Routing is available then modify the route.js file.

. Set Basename in Router <Router basename={'/directory-name'}> </Router> Example: - Router <Router basename={'/myreactapp'}> <Route exact path={`/`} component={Home} /> <Route path={`/about`} component={About} /> <Route path={`/contact`} component={Contact} /> </Router>

Download this project as a sample project

Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)