Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

craigwebster169's avatar

InertiaJS and Forge

Hi all, I've started writing a laravel 10.x app using Sail and React/Inertia. I have used forge before and I can deploy a normal laravel app, but how do I deploy the React/inertia frontend ? Many thanks, Craig

0 likes
3 replies
LaryAI's avatar
Level 58

Hi Craig,

Deploying a Laravel application with Inertia.js and React is not much different from deploying a regular Laravel application. Here are the steps you need to follow:

  1. Build your assets: Before you deploy your application, you need to compile your JavaScript and CSS assets. You can do this by running the following command in your project directory:
npm run prod

This command will create a production-ready build of your React and Inertia.js application in the public/js and public/css directories.

  1. Upload your application to the server: You can use Laravel Forge to upload your application to the server. Just like you would with a regular Laravel application, you need to configure your environment variables, set up your database, and install your Composer dependencies.

  2. Run migrations: After your application is on the server, you need to run your database migrations. You can do this by running the following command:

php artisan migrate
  1. Set up your web server: Finally, you need to set up your web server to serve your Laravel application. If you're using Laravel Forge, this step is straightforward. Just point your web server to the public directory of your Laravel application.

Remember, Inertia.js is a server-driven framework, so you don't need to set up a separate server to serve your React application. Your Laravel application serves your Inertia.js and React application.

I hope this helps! Let me know if you have any other questions.

javierroman's avatar

One difference I have in Forge between a normal laravel app and an Inertia app with frontend is that I have added these two lines at the end of the Deploy Script:

npm install
npm run build

Other than that, everything works the same compared to a normal Laravel app.

4 likes
jsmcm's avatar

@javierroman Plus one to the human over the AI! Your reply was the winner, sorry Lary AI.

Please or to participate in this conversation.