PHPackages                             robertboes/inertia-breadcrumbs - 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. robertboes/inertia-breadcrumbs

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

robertboes/inertia-breadcrumbs
==============================

Laravel package to automatically share breadcrumbs to Inertia

0.8.0(1y ago)56129.1k↑45.4%15MITPHPPHP ^8.1CI passing

Since Feb 18Pushed 1mo ago2 watchersCompare

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

READMEChangelog (10)Dependencies (16)Versions (17)Used By (0)

Laravel package to automatically share breadcrumbs to Inertia
=============================================================

[](#laravel-package-to-automatically-share-breadcrumbs-to-inertia)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5fde5dae8f91023e6b7c07b4303a9f595d948345f4dd4c368463ca55977f5ee1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f62657274626f65732f696e65727469612d62726561646372756d62732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/robertboes/inertia-breadcrumbs)[![Packagist PHP Version Support](https://camo.githubusercontent.com/676c0ff65f126cede573ce8d87311ade4ec30f90af9830c69a6c709926dfbc89/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f726f62657274626f65732f696e65727469612d62726561646372756d62733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/robertboes/inertia-breadcrumbs)[![GitHub Tests Action Status](https://camo.githubusercontent.com/86e302a3a53edb3ef9903b88c35a1c0596ad6f5a010c351ff7fabfd7c120603c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f526f62657274426f65732f696e65727469612d62726561646372756d62732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/robertboes/inertia-breadcrumbs/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/0fe19914591846510114334d62d220f0105e0ea3383d045ef2b8b04c794c6eb8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f526f62657274426f65732f696e65727469612d62726561646372756d62732f70696e742e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/RobertBoes/inertia-breadcrumbs/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain++)[![GitHub tag (latest SemVer)](https://camo.githubusercontent.com/6605bd157e7d83d6a2df35189e7e50300af77010b9fde43f19fe39b44be69dfe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f526f62657274426f65732f696e65727469612d62726561646372756d62733f6c6162656c3d6c617465737425323076657273696f6e267374796c653d666c61742d737175617265)](https://github.com/RobertBoes/inertia-breadcrumbs/releases/latest)[![Total Downloads](https://camo.githubusercontent.com/a4cb318460c46dcbdd056df8454d9dd8ffe06a1c9025884ba3f7acd38782edca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f62657274626f65732f696e65727469612d62726561646372756d62732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/robertboes/inertia-breadcrumbs)[![GitHub](https://camo.githubusercontent.com/8c9842005ff3c652f94dc7d920d96ced756b3e12aa40fcfb77898e7f829fdf9d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f526f62657274426f65732f696e65727469612d62726561646372756d62733f7374796c653d666c61742d737175617265)](https://github.com/RobertBoes/inertia-breadcrumbs/blob/main/LICENSE.md)

This package automatically shares breadcrumbs as Inertia props in a standardized way, with support for multiple breadcrumb packages.

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

[](#installation)

You can install the package via composer:

```
composer require robertboes/inertia-breadcrumbs
```

You can publish the config file with:

```
php artisan vendor:publish --tag="inertia-breadcrumbs-config"
```

Next step is to install one of the following packages to manage your breadcrumbs, or use the built-in closure collector:

- [diglactic/laravel-breadcrumbs](https://github.com/diglactic/laravel-breadcrumbs)
- [tabuna/breadcrumbs](https://github.com/tabuna/breadcrumbs)
- [glhd/gretel](https://github.com/glhd/gretel)
- Built-in closure collector (no additional package required)

Configure your breadcrumbs as explained by the package you've chosen.

Update your `config/inertia-breadcrumbs.php` configuration to use the correct collector:

```
// diglactic/laravel-breadcrumbs
use RobertBoes\InertiaBreadcrumbs\Collectors\DiglacticBreadcrumbsCollector;

return [
    'collector' => DiglacticBreadcrumbsCollector::class,
];

// tabuna/breadcrumbs
use RobertBoes\InertiaBreadcrumbs\Collectors\TabunaBreadcrumbsCollector;

return [
    'collector' => TabunaBreadcrumbsCollector::class,
];

// glhd/gretel
use RobertBoes\InertiaBreadcrumbs\Collectors\GretelBreadcrumbsCollector;

return [
    'collector' => GretelBreadcrumbsCollector::class,
];

// Built-in closure collector
use RobertBoes\InertiaBreadcrumbs\Collectors\ClosureBreadcrumbsCollector;

return [
    'collector' => ClosureBreadcrumbsCollector::class,
];
```

Usage
-----

[](#usage)

No matter which third party package you're using, this package will always share breadcrumbs to Inertia in the following format:

```
[
    {
        "title": "Dashboard",
        "url": "http://localhost/dashboard"
    },
    {
        "title": "Profile",
        "url": "http://localhost/dashboard/profile",
        "current": true
    },
    {
        "title": "Breadcrumb without URL"
    }
]
```

Note

Note that due to package differences, URLs are always present when using `glhd/gretel`, but are otherwise optional.

An example to render your breadcrumbs in Vue 3 could look like the following:

```

                {{ crumb.title }}
                {{ crumb.title }}

```

Using the closure collector
---------------------------

[](#using-the-closure-collector)

If you don't want to install a third-party breadcrumb package, you can use the built-in closure collector. This allows you to define breadcrumbs directly using closures, either in a service provider or in your controllers.

Update your `config/inertia-breadcrumbs.php` to use the `ClosureBreadcrumbsCollector`:

```
use RobertBoes\InertiaBreadcrumbs\Collectors\ClosureBreadcrumbsCollector;

return [
    'collector' => ClosureBreadcrumbsCollector::class,
];
```

Then define your breadcrumbs by route name. You can do this in a service provider:

```
