PHPackages                             tofandel/inertia-bundle - 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. [Framework](/categories/framework)
4. /
5. tofandel/inertia-bundle

ActiveSymfony-bundle[Framework](/categories/framework)

tofandel/inertia-bundle
=======================

A Symfony adapter for Inertia.js

v4.0.0(1y ago)47.1k↓71.4%MITPHPPHP ^8CI failing

Since Aug 10Pushed 1y agoCompare

[ Source](https://github.com/Tofandel/inertia-bundle)[ Packagist](https://packagist.org/packages/tofandel/inertia-bundle)[ RSS](/packages/tofandel-inertia-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (19)Versions (36)Used By (0)

Inertia.js Symfony Adapter
==========================

[](#inertiajs-symfony-adapter)

[![CI](https://github.com/rompetomp/inertia-bundle/workflows/CI/badge.svg)](https://github.com/rompetomp/inertia-bundle/actions)[![StyleCI](https://camo.githubusercontent.com/7b2a3625cc7b9f1f6f94e5397ef93fa77b9d70c15590e89e6a852e560120fda6/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3230313438343235332f736869656c643f7374796c653d666c6174)](https://github.styleci.io/repos/201484253)

This is a Inertia.js server-side adapter based on [inertia-laravel](https://github.com/inertiajs/inertia-laravel), but for Symfony 5 and 6.

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

[](#installation)

First, make sure you have the twig, encore and serializer recipe:

```
composer require twig encore symfony/serializer-pack
```

Install using Composer:

```
composer require rompetomp/inertia-bundle
```

```
yarn add @inertiajs/inertia
```

Setup root template
-------------------

[](#setup-root-template)

The first step to using Inertia is creating a root template. We recommend using `app.html.twig`. This template should include your assets, as well as the `inertia(page)` function

```

    {% block stylesheets %}
        {{ encore_entry_link_tags('app') }}
    {% endblock %}
    {{ inertiaHead(page) }}

{{ inertia() }}
{% block javascripts %}
    {{ encore_entry_script_tags('app') }}
{% endblock %}

```

The `inertia()` function is a helper function for creating our base `div`. It includes a `data-page` attribute which contains the initial page information. This is what it looks like:

```
