Reputation: 1883
I have reactjs
app, it's my first time that want to deploy/build my app, I know it's simply can do:
npm run build
I used this on a very simple react app before, it work fine, but now I want to deploy my react app that use react-router-dom
, after I run npm run build
, index.html
is blank, it's okay maybe, because I don't have a route for home page, for example one of my page in develop mode:
<Switch>
...
<Route exact path='/User/Login' component={Login}></Route>
...
</Switch>
/User/Login
How can I access this page after deploy? I am super newbie to reactjs, I don't know how to handle this, many search, but can't find anything useful in my native language.
Packages.json
"name": "sample",
"homepage": "http://example.com/react/",
"version": "0.1.0",
"private": true,
Upvotes: 1
Views: 237
Reputation: 402
React App needs a node server to be hosted. If you want to host on linux/Ubuntu server then you will need to install node.js from NVMFull Tutorial or you can go for Gatsby to create static react apps.
You can host your react app on AWS/Heroku etc.
If you are deploying react build for learning purpose only then you can use static server locally:
npm i serve -g
serve -s build
Upvotes: 2