vincent15000's avatar

How to check if SSR is used ?

Hello,

How is it possible to check if SSR works fine in dev mode ?

The documentation says that if running in dev mode (composer run dev), it's not necessary to execute php artisan inertia:start-ssr, it's handled automatically by ViteJS.

How is it possible to check if the pages are really rendered by the backend ?

0 likes
2 replies
LaryAI's avatar
Level 58

Certainly! Here’s a solution with an explanation and practical steps:


To check if Server-Side Rendering (SSR) is working correctly with Inertia.js and Laravel in dev mode, you want to confirm that your pages are initially rendered on the server, not just on the client.

How Laravel + Inertia SSR Works in Dev Mode

When running composer run dev (which typically executes vite), Vite automatically starts the Inertia SSR server in development mode, so you don’t need to manually run php artisan inertia:start-ssr.

Ways to Confirm SSR is Working

1. View Page Source in Browser

Open any Inertia-loaded page and right-click → View Page Source. If SSR is enabled, you should see your markup rendered as HTML elements (with actual content, not just a root <div id="app"></div>). If you only see a root container div and JavaScript, SSR isn’t working.

Example: Without SSR, page source will look like:

<div id="app" data-page="..."></div>
<script src="/js/app.js"></script>

With SSR, you’ll see the actual rendered markup:

<div id="app" data-page="...">
  <div>
    <!-- Your SSR-rendered components here -->
    <h1>Welcome, John</h1>
    ...
  </div>
</div>

2. Temporarily Remove JavaScript & Refresh

  • Open DevTools → Network tab.
  • Throttle or block JavaScript (or disable it in your browser).
  • Refresh the page.
  • If SSR is working: You’ll still see content.
  • If not: The page will be blank or nearly blank.

3. Look for SSR Logs in Terminal

When you run composer run dev, you should see Vite starting up, and it should mention something like "SSR server running at..." in the logs.

4. Console Warnings

If there’s an SSR mismatch or error, the browser console will usually show a warning about hydration errors from Vue/React.


Summary

  • Open view source and look for your actual page content, not just a root div.
  • Disable JavaScript, refresh, and check if any content appears.
  • Check your terminal for SSR server startup logs.

If the rendered source shows your HTML content (not just id="app"), then SSR is working.


Let me know if you need more detail on any step!

JussiMannisto's avatar
Level 50

View the page source. If you see fully rendered html, SSR works. If you see an empty div in the body, it's not working.

Note that only the first page is rendered on the server, and other pages are rendered client-side when you navigate to them. This is by design.

1 like

Please or to participate in this conversation.