---
title: Inertia server side rendering on Laravel Vapor
url: "https://aaronfrancis.com/writing/inertia-server-side-rendering-on-laravel-vapor"
path: "/writing/inertia-server-side-rendering-on-laravel-vapor"
type: technical_article
author: Aaron Francis
published: 2022-01-09
updated: 2026-11-10
topic: "Laravel & PHP"
description: "How to use Inertia's SSR features in a serverless environment like Laravel Vapor."
keywords: [inertia ssr, laravel vapor, sidecar, aws lambda, serverless rendering, laravel, node.js, jetstream, long-running processes, ssr]
site_index: "/llms.txt"
keyword_index: "/llms/keywords.txt"
---

# Inertia server side rendering on Laravel Vapor

Inertia.js now provides fully-featured [server-side rendering](https://inertiajs.com/server-side-rendering), removing one of the main reasons people might have shied away from it in the past. 

Inertia provides a few libraries to help you run a small Node.js server in the background. It works like this:

- a request comes into your Laravel application
- Inertia sends a request to the running Node process
- the Node process renders HTML and returns it to your Laravel application
- Inertia inserts it into the page as HTML.

The Inertia team has provided just about everything you need to run SSR on a traditional server like Forge or Heroku.

The only drawback to this approach is that _you have to have a long-running Node process._ This is obviously impossible on a serverless platform like Laravel Vapor, where there are no long-running processes!

## Enter Sidecar

[Sidecar](https://github.com/hammerstonedev/sidecar) is a Laravel package that allows you to package, create, deploy,
and execute AWS Lambda functions directly from your Laravel application.

Sidecar handles all the hard parts about interacting with AWS Lambda, and leaves you with and nice interface to execute functions, like this:

Lambda currently supports the following languages:

- Node.js 14
- Node.js 12
- Node.js 10
- Python 3.8
- Python 3.7
- Python 3.6
- Python 2.7
- Ruby 2.7
- Ruby 2.5
- Java 11
- Java 8
- Go 1.x
- .NET Core 3.1
- .NET Core 2.1

You can also provide a container runtime, and [PHP support is coming soon](https://twitter.com/aarondfrancis/status/1478030228362600451).

Sidecar has already been used in production to render tens of millions of Inertia SSR requests.

> Running like clockwork for months. Tens of millions of server side render requests. Runs like clockwork :)
>
> — Greg Skerman · @GregSkerman · January 8, 2022 (https://twitter.com/GregSkerman/status/1479673213156151297)

## Sidecar + Inertia

Looking at the process from above, we'll just swap out "Node process" with "Sidecar function."

- a request comes into your Laravel application
- Inertia sends a request to the ~~running Node process~~ Sidecar function
- the ~~Node process~~ Sidecar function renders HTML and returns it to your Laravel application
- Inertia inserts it into the page as HTML.

Instead of running a process, the rendering will be done inside of a Lambda on AWS. 

We have provided a [sidecar-inertia package](https://github.com/hammerstonedev/sidecar-inertia) that handles most of it for you, and includes the documentation. We have also created a [Jetstream + Inertia + Sidecar SSR demo repo](https://github.com/hammerstonedev/sidecar-inertia-demo) if you want to take a look at the full thing.

The repo will contain full the full documentation, but I'll cover some of the highlights here.

When it comes to rendering SSR, Inertia makes it super easy to swap out renderers. In our case, we'll use the provided `SidecarGateway`.

```php
namespace App\Providers;

use Hammerstone\Sidecar\Inertia\SidecarGateway;
use Illuminate\Support\ServiceProvider;
use Inertia\Ssr\Gateway;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        // Use Sidecar to run Inertia SSR.
        $this->app->instance(Gateway::class, new SidecarGateway);
    }
}
```

The package ships with a `\Hammerstone\Sidecar\Inertia\SSR` function, which is what we'll deploy to AWS. 

You can take a look at the full contents of the function here: [github.com/hammerstonedev/sidecar-inertia/src/SSR.php](https://github.com/hammerstonedev/sidecar-inertia/blob/main/src/SSR.php).

After you have [configured Sidecar](https://hammerstone.dev/sidecar/docs/main/configuration), you can run `php artisan sidecar:deploy --activate` and you should see output like this: 

```text
[Sidecar] Deploying Hammerstone\Sidecar\Inertia\SSR to Lambda as `SC-Demo-local-Inertia-SSR`.
          ↳ Environment: local
          ↳ Package Type: Zip
          ↳ Runtime: nodejs14.x
          ↳ Executing beforeDeployment hooks
          ↳ Compiling Inertia SSR bundle.
          ↳ Running npx mix --mix-config=webpack.ssr.mix.js
          ↳ JavaScript SSR bundle compiled!
          ↳ Function already exists, potentially updating code and configuration.
          ↳ Packaging files for deployment.
          ↳ Creating a new zip file.
          ↳ Zip file created at s3://sidecar-us-east-2-xxxx/sidecar/001-3f887xxxxx.zip
          ↳ Function code and configuration updated.
[Sidecar] Activating function Hammerstone\Sidecar\Inertia\SSR.
          ↳ Environment variables not managed by Sidecar. Skipping.
          ↳ Activating Version 5 of SC-Demo-local-Inertia-SSR.
```

Now your function is active on Lambda and SSR is ready to be used!

**This SSR Lambda is _completely independent_ from Laravel Vapor, it just happens to use Lambda like Vapor does.**

This method will work locally, on Vapor, or on a server. Basically anywhere you can run PHP you can call this function. In fact, the best way to debug your function is to deploy and run it from your local machine!

Take a look at the full docs on the [sidecar-inertia package](https://github.com/hammerstonedev/sidecar-inertia) and
review the [docs for Sidecar](https://hammerstone.dev/sidecar/docs/main/overview) as well.

If you run into any issues with [Sidecar SSR](https://github.com/hammerstonedev/sidecar-inertia), please open them on the repo, and if you have questions about [Sidecar](https://github.com/hammerstonedev/sidecar) itself please open an issue there!

---

## Related on aaronfrancis.com

- [Hammerstone, a History](/podcast/hammerstone-a-history-2f8ad77f) *(Podcast · 2021-09-17 · shared: sidecar, aws lambda, laravel)*
- [Riding Sidecar with Aaron Francis](/podcast/riding-sidecar-with-aaron-francis-68srka) *(Podcast · 2021-08-21 · shared: sidecar, aws lambda, laravel)*
- [Refine, Sidecar, Laravel, and Serverless](/podcast/refine-sidecar-laravel-and-serverless-msxhy3) *(Podcast · 2022-03-14 · shared: sidecar, laravel, aws lambda)*
- [Adding a microservice to your monolith](/writing/adding-a-microservice-to-your-monolith) *(Article · 2022-02-17 · shared: sidecar, aws lambda, laravel)*
- [Using Ziggy with Inertia server side rendering](/writing/using-ziggy-with-inertia-server-side-rendering) *(Article · 2022-01-08 · shared: inertia ssr, ssr, sidecar)*

## Relevant Resources from Aaron Francis

- **[Solo](https://soloterm.com)** (overview on site: [/software](/software)): All-in-one agentic development platform and terminal workspace built by Aaron Francis for orchestrating processes and AI coding agents.

## Search aaronfrancis.com (2-Hop Static Keyword Index)

Pick the alphabetical shard matching any topic to find exact pages across all articles, newsletters, videos, talks, and podcast transcripts (every shard is < 40 KB):
[A-B](/llms/keywords/a-b.txt) · [C](/llms/keywords/c.txt) · [D-E](/llms/keywords/d-e.txt) · [F-G](/llms/keywords/f-g.txt) · [H-J](/llms/keywords/h-j.txt) · [K-L](/llms/keywords/k-l.txt) · [M-N](/llms/keywords/m-n.txt) · [O-P](/llms/keywords/o-p.txt) · [Q-R](/llms/keywords/q-r.txt) · [S](/llms/keywords/s.txt) · [T-Z](/llms/keywords/t-z.txt) · [Directory](/llms/keywords.txt) · [Site Map](/llms.txt)

Shards for this page's topics: `inertia ssr` ([H-J](/llms/keywords/h-j.txt)), `laravel vapor` ([K-L](/llms/keywords/k-l.txt)), `sidecar` ([S](/llms/keywords/s.txt)), `aws lambda` ([A-B](/llms/keywords/a-b.txt)).

## About Aaron Francis (Current Context)

Aaron Francis is VP of Marketing and Community at [Laravel](https://laravel.com), founder of [Try Hard Studios](https://tryhardstudios.com), creator of [Solo](https://soloterm.com), co-host of [Mostly Technical](/podcast), and author of [Mastering Postgres](/courses), [High Performance SQLite](/courses), [MySQL for Developers](/courses), and [Screencasting.com](/courses). Full bio: [/about](/about) · Current focus: [/now](/now).
