reactjshostinger

I'm having trouble deploying a React App in Hostinger


I'm trying to deploy a React app that uses React Router v7 to Hostinger's shared hosting. When I run npm run build, the build command generates a folder with two subdirectories:

client and server.

However, I'm unable to find an index.html file in the output, which makes it difficult to deploy the app to Hostinger.

No index html

My plan is to upload the entire build folder (or its contents) into the public_html directory through Hostinger's file manager, but I’m unsure how to proceed since the index.html file is missing.

I’ve also tried using an .htaccess file to manage routing and redirection, but it hasn’t resolved the issue.

What is the correct way to deploy this React app to Hostinger, and how should I handle the missing index.html file?

Edit: I can view the build version correctly when i do it locally, using npm start, where i have this command:

 "start": "cross-env NODE_ENV=production react-router-serve ./build/server/index.js",

is there a way to get serve the website using the index.js?

🤔

Edit: I found out that hostinger can't manage Server Side Rendering (SSR), should i change to Client Side Rendering, and would this allow me to upload the website?


Solution

  • I FINALLY GOT IT!

    after hours of trying all kinds of things, it was the following solution:

    you have to go to the file react-router.config.ts and simply change ssr: from true to false

    then, when building the app it will provide a 100% static-friendly website

    ssr change