PHPackages                             robertboes/sidecar-inertia-vite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. robertboes/sidecar-inertia-vite

ActiveLibrary[API Development](/categories/api)

robertboes/sidecar-inertia-vite
===============================

A Sidecar function to run Inertia server-side rendering with Vite on Lambda.

v0.2.0-alpha(2y ago)181.7k↓100%10[1 issues](https://github.com/RobertBoes/sidecar-inertia-vite/issues)[1 PRs](https://github.com/RobertBoes/sidecar-inertia-vite/pulls)MITPHPPHP ^8.0

Since Dec 8Pushed 2y ago2 watchersCompare

[ Source](https://github.com/RobertBoes/sidecar-inertia-vite)[ Packagist](https://packagist.org/packages/robertboes/sidecar-inertia-vite)[ GitHub Sponsors](https://github.com/RobertBoes)[ RSS](/packages/robertboes-sidecar-inertia-vite/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (5)Used By (0)

Sidecar SSR for InertiaJS with Vite
===================================

[](#sidecar-ssr-for-inertiajs-with-vite)

> 🚨 Use this package with caution, as I'm still working on it

This package is based on [hammerstonedev/sidecar-inertia](https://github.com/hammerstonedev/sidecar-inertia). Aaron has done an amazing job with Sidecar and his original package lead me to figure out how to make it work with Vite.

Overview
--------

[](#overview)

This package provides a Sidecar function to run [Inertia server-side rendering](https://inertiajs.com/server-side-rendering) on AWS Lambda.

Sidecar packages, deploys, and executes AWS Lambda functions from your Laravel application.

- [Sidecar docs](https://hammerstone.dev/sidecar/docs/main/overview)
- [Sidecar GitHub](https://github.com/hammerstonedev/sidecar)

Enabling SSR
------------

[](#enabling-ssr)

Following the [official Inertia docs](https://inertiajs.com/server-side-rendering#enabling-ssr) on enabling SSR is a good place to start, but there are a few things you can skip:

- You do not need to `npm install @inertiajs/server`
- Come back here when you get to the "Building your application" section

I won't go into detail on how to setup SSR with Vite and Laravel, but the upcoming [Inertia docs](https://next.inertiajs.com/) have more detailed information along with the [Laravel docs](https://laravel.com/docs/9.x/vite)

By default the SSR gateway is disabled, you can enable this by setting `SIDECAR_INERTIA_VITE_ENABLED=true` in your `.env`or by adjusting [the configuration file](#publishing-configuration) to your liking.

Installation
------------

[](#installation)

To require this package, run the following:

```
composer require robertboes/sidecar-inertia-vite
```

This will install Sidecar as well.

Using the Sidecar Gateway
-------------------------

[](#using-the-sidecar-gateway)

This package automatically overwrites the Inertia SSR gateway if the config `sidecar-inertia-vite.ssr_gateway_enabled` is true.

If for some reason the gateway isn't properly overwritten you can do this in your own service provider like so:

```
namespace App\Providers;

use RobertBoes\SidecarInertiaVite\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);
    }
}
```

Publishing Configuration
------------------------

[](#publishing-configuration)

You can publish the configuration with the following command:

```
php artisan vendor:publish --provider="RobertBoes\SidecarInertiaVite\ServiceProvider" --tag="config"
```

Configuring Sidecar
-------------------

[](#configuring-sidecar)

If you haven't already, you'll need to configure Sidecar.

Publish the `sidecar.php` configuration file by running

```
php artisan sidecar:install
```

To configure your Sidecar AWS credentials interactively, you can run

```
php artisan sidecar:configure
```

The [official Sidecar docs](https://hammerstone.dev/sidecar/docs/main/configuration) go into much further detail.

Now update your `config/sidecar.php` to include the function shipped with this package.

```
