What commands do you use with Laravel + Inertia to run an SSR server?

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Mastering Server-Side Rendering with Laravel and Inertia: The Essential SSR Commands Explained

As developers leveraging the power of Laravel and Inertia, the desire for better SEO and improved initial page load times often pushes us toward Server-Side Rendering (SSR). While Inertia excels at bridging the gap between traditional MVC and modern frontend frameworks like Vue or React, implementing true SSR requires understanding how the backend orchestrates the rendering process.

Many developers encounter confusion when transitioning from a standard Inertia setup to an SSR setup, often struggling with which commands to run and which ports to use. This post will demystify the process, providing a clear roadmap for running a robust Laravel + Inertia SSR application.

Understanding the Baseline: Inertia Without SSR

Before diving into SSR, let’s quickly revisit your existing setup. When you use php artisan serve alongside npm run dev, you are typically running two separate services: one serving the PHP backend (APIs, Blade views) and another serving the compiled Vue/Inertia assets. This setup works perfectly for traditional SPA routing but doesn't inherently perform server-side HTML rendering required for optimal SEO.

The Commands for True SSR Implementation

To enable seamless Server-Side Rendering with Inertia, you need to shift focus from simple API serving to utilizing Laravel’s rendering capabilities specifically designed for this purpose. Forget mixing standard php artisan serve directly with the SSR tooling; there is a dedicated sequence required.

The correct flow involves preparing your assets and then launching the specialized SSR server component provided by the Inertia ecosystem.

Step 1: Asset Preparation

First, you must ensure your frontend assets are compiled and ready for the server to consume. This step prepares the necessary JavaScript bundles that will be injected into the HTML response.

npm run build

This command compiles your Vue components and assets, ensuring that the necessary client-side code is bundled correctly before the server attempts to render the page.

Step 2: Launching the SSR Server

Instead of relying on a generic PHP server, you must use the dedicated Inertia command designed to handle the rendering logic. This command hooks into Laravel’s routing and view system to generate the full HTML response.

php artisan inertia:start-ssr

When you execute this command, Inertia handles setting up the necessary routes and middleware to intercept the request, perform the server-side rendering using your Laravel controllers and views, and inject the resulting HTML alongside the necessary JavaScript data for hydration on the client side.

Resolving Port Conflicts and Troubleshooting

The confusion regarding ports (like 8000 vs. 13714) arises because you are trying to run two independent servers simultaneously. In a well-configured SSR environment, the inertia:start-ssr command is designed to be the primary entry point for your application, handling both routing and rendering within a single process or correctly configured set of ports defined by Laravel's configuration files.

If you are still encountering connection errors, it often means one of two things:

  1. The environment variables (like APP_URL) are misconfigured in your .env file, causing the server to fail during route resolution.
  2. You are attempting to run the standard php artisan serve and the SSR command simultaneously, which leads to port conflicts and unpredictable behavior.

Best Practice: For a pure Inertia SSR implementation, you should rely solely on the commands provided by the framework (like npm run build followed by php artisan inertia:start-ssr). This ensures that all parts of the application—backend logic, view rendering, and asset delivery—are coordinated correctly, aligning with Laravel’s principles for building robust applications.

Conclusion

Implementing Server-Side Rendering in a Laravel + Inertia stack is less about juggling multiple server commands and more about following the framework's intended sequence. By using npm run build to prepare assets and then leveraging php artisan inertia:start-ssr, you ensure that your application correctly executes the necessary steps to generate fully rendered HTML for superior SEO. Always prioritize the official Inertia documentation when setting up complex features like SSR, as it provides the most accurate guidance for leveraging the capabilities of Laravel and achieving high-performing web experiences.