Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React app without server

How can a react application be packaged and hosted without a server. The application is purely front end. Tried building the application npm run build but that created a build which would require a server to be hosted on.

like image 805
Pikachu-go Avatar asked Feb 19 '26 02:02

Pikachu-go


1 Answers

Well no, it doesn't require a server to host it. As you said its just front end. HOWEVER, if you want to navigate OTHER than via scripted navigation you'll need a server. Simply building your project and serving the index file as a static asset is sufficient to run the code on shared hosting. Once the index file has finished downloading it will execute the javascript thats imported (react in this case). but if you try to go to say, website.com/blah its not going to work as rendering specific routes in react requires rendering and returning javascript. Something you need a server for.

The react bundle is self executing, at least with create-react-app. You shouldn't have any issues.

like image 104
Joshua Underwood Avatar answered Feb 20 '26 16:02

Joshua Underwood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!