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

1stevengrant's avatar

Vapor Inertia SSR

I've been investigating the lift of our app over to using Inertia but we'll need SSR.

I've looked at Aaron Francis' work on Sidecar Inertia and some of the PRs that have been made against that package with a view to getting things working.

I'm trying with a vanilla Breeze app and SSR is great locally.

I'd be happy to pay someone for an hour or so of their time if they'd be able to point out where I'm falling down.

I don't get any errors deploying my Lambda function.

0 likes
3 replies
LaryAI's avatar
Level 58

It seems like you're looking for assistance with setting up Server-Side Rendering (SSR) for an Inertia.js application on Laravel Vapor, possibly using Aaron Francis' Sidecar package. While I can't offer one-on-one paid support, I can certainly guide you through some steps to troubleshoot and set up SSR for Inertia.js on Vapor.

First, ensure that you have followed all the necessary steps to set up SSR with Inertia.js:

  1. Install the necessary SSR dependencies for Inertia.js.
  2. Configure your server to handle SSR. This typically involves setting up a Node.js server that can render your Vue/React components on the server.
  3. Modify your Inertia.js pages to be SSR-compatible, which may involve ensuring that any client-side APIs are only called when in the browser.

For deploying SSR with Laravel Vapor, you'll need to make sure that your Lambda function is set up correctly to handle SSR requests. Here's a general outline of what you need to do:

  1. Create a Lambda Function for SSR: Use the Sidecar package to create a Lambda function that will handle the SSR. This function will need to have Node.js and all necessary dependencies installed.

  2. Configure Vapor: Make sure your vapor.yml file is configured to use the Lambda function for SSR. You'll need to specify the correct handler and runtime for the function.

  3. Deploy: Deploy your application using Vapor. If there are no errors during deployment, your SSR should be set up.

  4. Debugging: If SSR isn't working as expected, you'll need to debug. Check the Lambda function logs in AWS CloudWatch to see if there are any runtime errors. Ensure that the Lambda function has enough memory and timeout settings configured.

Here's a basic example of how you might configure a Sidecar function for SSR:

use Hammerstone\Sidecar\LambdaFunction;
use Hammerstone\Sidecar\Runtime;

class RenderInertiaApp extends LambdaFunction
{
    public function handler()
    {
        return 'index.handler';
    }

    public function runtime()
    {
        return Runtime::NODEJS_14_X;
    }

    public function package()
    {
        // Define the files and commands necessary to package your SSR app.
    }
}

And in your vapor.yml, you might have something like this:

environments:
  production:
    memory: 1024
    timeout: 30
    build:
      - 'npm install && npm run prod'
    deploy:
      - 'php artisan sidecar:deploy --activate'

Remember, this is a very high-level overview and your actual implementation details will vary based on your application's specific needs. If you're still having trouble, consider reaching out to the community on the Laracasts forum or the Inertia.js Discord for more interactive help.

Please or to participate in this conversation.