PHPackages                             guansunyata/laravel-server-side-rendering - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. guansunyata/laravel-server-side-rendering

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

guansunyata/laravel-server-side-rendering
=========================================

Server side rendering JavaScript in your Laravel application (forked from spatie/laravel-server-side-rendering)

1.1.0(7y ago)0124MITPHPPHP ^7.0

Since Jan 18Pushed 7y ago1 watchersCompare

[ Source](https://github.com/guAnsunyata/laravel-server-side-rendering)[ Packagist](https://packagist.org/packages/guansunyata/laravel-server-side-rendering)[ Docs](https://github.com/guansunyata/laravel-server-side-rendering)[ RSS](/packages/guansunyata-laravel-server-side-rendering/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (4)Versions (30)Used By (0)

Server side rendering JavaScript in your Laravel application
============================================================

[](#server-side-rendering-javascript-in-your-laravel-application)

[![Latest Version on Packagist](https://camo.githubusercontent.com/88cdcac96782e45ed38d5bba26841f3886a5dd70ca4379725236e164b53a27dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d7365727665722d736964652d72656e646572696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-server-side-rendering)[![Build Status](https://camo.githubusercontent.com/8f1b67b4a4acc37af03f9f811881deca49c079e2a49883af8e270964fab7beb6/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7370617469652f6c61726176656c2d7365727665722d736964652d72656e646572696e672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/spatie/laravel-server-side-rendering)[![SensioLabsInsight](https://camo.githubusercontent.com/4f53b6dcfb7c41afddd5b2bbe4e49d0b9b2bb94a221b718b1dc51afeecb37fc4/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f7878787878787878782e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/xxxxxxxxx)[![Quality Score](https://camo.githubusercontent.com/83800fb495a4854627050f68338606dfa5337d85316efa048669b7bb22df0f5f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7370617469652f6c61726176656c2d7365727665722d736964652d72656e646572696e672e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/spatie/laravel-server-side-rendering)[![Total Downloads](https://camo.githubusercontent.com/113551f2c4f347f53bf7d5f671a58a43fe4de91928caa75048a8068eb28e5081/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d7365727665722d736964652d72656e646572696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-server-side-rendering)

Making server side rendering a bit less hard in Laravel.

```

        My server side rendered app

        {!! ssr('js/app-server.js') !!}

```

This package is a Laravel bridge for the [spatie/server-side-rendering](https://github.com/spatie/server-side-rendering) library. Before getting started, dig through the readme to learn about the underlying concepts and caveats. This readme also assumes you already have some know-how about building server rendered JavaScript apps.

Vue and React example apps are available at [spatie/laravel-server-side-rendering-examples](https://github.com/spatie/laravel-server-side-rendering-examples) if you want to see it in action.

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

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-server-side-rendering
```

The service provider and `Ssr` alias will be automatically registered.

You can optionally publish the config file if you want to tweak things.

```
php artisan vendor:publish --provider="Spatie\Ssr\SsrServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

### Prerequisites

[](#prerequisites)

First you'll need to pick an engine to execute your scripts. The server-side-rendering library ships with V8 and Node engines. By default, the package is configured to use node, since you probably already have that installed on your system.

Set up the `NODE_PATH` environment variable in your .env file to get started:

```
NODE_PATH=/path/to/my/node

```

You'll also need to ensure that a `storage/app/ssr` folder exists, or change the `ssr.node.temp_path` config value to something else.

If you'd rather use the V8 engine, you can skip the previous two steps. You'll need to have the [v8js extension](https://github.com/phpv8/v8js) installed though.

### Configuration

[](#configuration)

Besides the above, no configuration's required. If you need to tweak things anyway, the [config file](https://github.com/spatie/laravel-server-side-rendering/blob/master/config/ssr.php) is well documented.

### Setting up your scripts

[](#setting-up-your-scripts)

You'll need to build two scripts: a server script and a client script. Refer to your frontend-framework-of-choice's documentation on how to build those.

```
mix.js('resources/assets/js/app-client.js', 'public/js')
   .js('resources/assets/js/app-server.js', 'public/js');
```

The server script should be passed to the `ssr` function, the client script should be loaded manually. The package assumes you're using Laravel Mix, and will resolve the path for you. You can opt out of this behaviour by setting `mix` to `false` in the config file.

```
{!! ssr('js/app-server.js) !!}

```

Your server script should call a `dispatch` function to send the rendered html back to the view. Here's a quick example of a set of Vue scripts for a server-rendered app. Read the [spatie/server-side-rendering](https://github.com/spatie/server-side-rendering#core-concepts) readme for a full explanation of how everything's tied together.

```
// resources/assets/js/app.js

import Vue from 'vue';
import App from './components/App';

export default new Vue({
    render: h => h(App),
});
```

```
// resources/assets/js/app-client.js

import app from './app';

app.$mount('#app');
```

```
// resources/assets/js/app-server.js

import app from './app';
import renderVueComponentToString from 'vue-server-renderer/basic';

renderVueComponentToString(app, (err, html) => {
    if (err) {
        throw new Error(err);
    }

    dispatch(html);
});
```

### Rendering an app in your view

[](#rendering-an-app-in-your-view)

The package exposes an `ssr` helper to render your app.

```

        My server side rendered app

        {!! ssr('js/app-server.js')->render() !!}

```

A facade is available too.

```

        My server side rendered app

        {!! Ssr::entry('js/app-server.js')->render() !!}

```

Rendering options can be chained after the function or facade call.

```

        My server side rendered app

        {!! ssr('js/app-server.js')->context('user', $user)->render() !!}

```

Available options are documented at [spatie/server-side-rendering](https://github.com/spatie/server-side-rendering#rendering-options).

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Postcardware
------------

[](#postcardware)

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).

Credits
-------

[](#credits)

- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)

Support us
----------

[](#support-us)

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/spatie). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 77.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Recently: every ~0 days

Total

21

Last Release

2745d ago

Major Versions

0.2.5 → 1.0.12018-09-04

0.3.0 → 1.0.1-patch-1.22018-11-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b5cead4cebadfe7dca95f383c8914a8db7bd2d8c19151d90a0f17966e6c5b78?d=identicon)[guansunyata](/maintainers/guansunyata)

---

Top Contributors

[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (28 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (4 commits)")[![guAnsunyata](https://avatars.githubusercontent.com/u/11704825?v=4)](https://github.com/guAnsunyata "guAnsunyata (2 commits)")[![andredewaard](https://avatars.githubusercontent.com/u/7560637?v=4)](https://github.com/andredewaard "andredewaard (1 commits)")[![traubisoda](https://avatars.githubusercontent.com/u/1913152?v=4)](https://github.com/traubisoda "traubisoda (1 commits)")

---

Tags

spatieSSRlaravel-server-side-rendering

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/guansunyata-laravel-server-side-rendering/health.svg)

```
[![Health](https://phpackages.com/badges/guansunyata-laravel-server-side-rendering/health.svg)](https://phpackages.com/packages/guansunyata-laravel-server-side-rendering)
```

###  Alternatives

[spatie/laravel-server-side-rendering

Server side rendering JavaScript in your Laravel application

672507.5k3](/packages/spatie-laravel-server-side-rendering)[spatie/laravel-collection-macros

A set of useful Laravel collection macros

1.9k5.7M29](/packages/spatie-laravel-collection-macros)[spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

1.5k4.7M20](/packages/spatie-laravel-cookie-consent)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[spatie/laravel-multitenancy

Make your Laravel app usable by multiple tenants

1.3k2.9M16](/packages/spatie-laravel-multitenancy)[spatie/laravel-html

A fluent html builder

8376.4M72](/packages/spatie-laravel-html)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
