PHPackages                             spatie/laravel-navigation - 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. spatie/laravel-navigation

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

spatie/laravel-navigation
=========================

Manage menus, breadcrumbs, and other navigational elements in Laravel apps

1.3.0(1y ago)5711.0M—2.1%329MITPHPPHP ^8.0CI passing

Since Feb 1Pushed 3mo ago12 watchersCompare

[ Source](https://github.com/spatie/laravel-navigation)[ Packagist](https://packagist.org/packages/spatie/laravel-navigation)[ Docs](https://github.com/spatie/laravel-navigation)[ Fund](https://spatie.be/open-source/support-us)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-laravel-navigation/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (6)Versions (9)Used By (9)

Manage menus, breadcrumbs, and other navigational elements in Laravel apps
==========================================================================

[](#manage-menus-breadcrumbs-and-other-navigational-elements-in-laravel-apps)

[![Latest Version on Packagist](https://camo.githubusercontent.com/053c1c5b1eb31a94d8f100ae71de233bef4c27dc045f67c25c3610332a735313/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d6e617669676174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-navigation)[![run-tests](https://github.com/spatie/laravel-navigation/workflows/run-tests/badge.svg)](https://github.com/spatie/laravel-navigation/workflows/run-tests/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/c641047b808aad23c94330c816c7916fd0bd3db1dac2b29371cd018b5875ee5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d6e617669676174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-navigation)

Laravel Navigation is meant to be the spiritual successor of [Laravel Menu](https://github.com/spatie/laravel-menu). Laravel Menu will still be actively maintained, but there are a few principal differences between the two packages.

The main goal of Laravel Menu is to build HTML menus from PHP. Laravel Navigation describes an application's navigation tree, which can be used as a base to create navigational elements like menus and breadcrumbs. Laravel Menu has a rich API for HTML generation. Laravel Navigation doesn't do any HTML generation (although we might ship some Blade files in the future). Instead, Laravel Navigation should give you the flexibility to build your own UI without worrying about the complexity of navigation trees and active state. Think of it as a [renderless component](https://adamwathan.me/renderless-components-in-vuejs/).

```
Navigation::make()
    ->add('Home', route('home'))
    ->add('Blog', route('blog.index'), fn (Section $section) => $section
        ->add('All posts', route('blog.index'))
        ->add('Topics', route('blog.topics.index'))
    )
    ->addIf(
        Auth::user()->isAdmin(),
        'Admin',
        route('admin.index'),
        fn (Section $section) => $section->add('Create post', route('blog.create'))
    );
```

If you want to register your navigation in a service provider, which is recommended, you can use the [Laravel container events](https://laravel.com/docs/10.x/container#container-events) to add items to the navigation.

```
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Spatie\Navigation\Navigation;
use Spatie\Navigation\Section;

class NavigationServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->app->resolving(Navigation::class, function (Navigation $navigation): Navigation {
            return $navigation
                ->add('Home', route('home'))
                ->add('Blog', route('blog.index'), fn (Section $section) => $section
                    ->add('All posts', route('blog.index'))
                    ->add('Topics', route('blog.topics.index'))
                )
                ->addIf(
                    Auth::user()->isAdmin(),
                    'Admin',
                    route('admin.index'),
                    fn (Section $section) => $section->add('Create post', route('blog.create'))
                );
        });
    }
}
```

A navigation object can be rendered to a tree, or to breadcrumbs.

Some examples when visiting `/blog/topics/laravel`:

```
// Render to tree
Navigation::make()->tree();
```

```
[
    { "title": "Home", "url": "/", "active": false, "attributes": [], "children": [], "depth": 0 },
    {
        "title": "Blog",
        "url": "/blog",
        "active": false,
        "attributes": [],
        "children": [
            { "title": "All posts", "url": "/blog", "active": false, "attributes": [], "children": [], "depth": 1 },
            { "title": "Topics", "url": "/blog/topics", "active": true, "attributes": [], "children": [], "depth": 1 }
        ],
        "depth": 0
    },
    {
        "title": "Admin",
        "url": "/admin",
        "active": false,
        "attributes": [],
        "children": [
            { "title": "Create post", "url": "/blog/create", "active": false, "attributes": [], "children": [], "depth": 1 }
        ],
        "depth": 0
    }
]
```

```
// Append additional pages in your controller
Navigation::make()->activeSection()->add($topic->name, route('blog.topics.show', $topic));

// Render to breadcrumbs
Navigation::make()->breadcrumbs();
```

```
[
    { "title": "Blog", "url": "/blog", "attributes": [] },
    { "title": "Topics", "url": "/blog/topics", "attributes": [] },
    { "title": "Laravel", "url": "/blog/topics/laravel", "attributes": [] }
]
```

```
// Render the current section
Navigation::make()->current();
```

```
{ "title": "Home", "url": "/", "attributes": [] }
```

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

[](#support-us)

[![](https://camo.githubusercontent.com/024f4be269d14169f4bff971abd158129fc5c3ce255cf3204fe02e93313364aa/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d6e617669676174696f6e2e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-navigation)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-navigation
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

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

License
-------

[](#license)

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

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance60

Regular maintenance activity

Popularity60

Solid adoption and visibility

Community35

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor4

4 contributors hold 50%+ of commits

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 ~170 days

Recently: every ~208 days

Total

6

Last Release

606d ago

PHP version history (2 changes)1.0PHP ^8.0|^8.1

1.2.1PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (23 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (15 commits)")[![alexmanase](https://avatars.githubusercontent.com/u/10696975?v=4)](https://github.com/alexmanase "alexmanase (14 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (12 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (8 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (7 commits)")[![innocenzi](https://avatars.githubusercontent.com/u/16060559?v=4)](https://github.com/innocenzi "innocenzi (6 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (6 commits)")[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (5 commits)")[![choowx](https://avatars.githubusercontent.com/u/63900628?v=4)](https://github.com/choowx "choowx (3 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (3 commits)")[![martinszemitis](https://avatars.githubusercontent.com/u/77287264?v=4)](https://github.com/martinszemitis "martinszemitis (2 commits)")[![beholdr](https://avatars.githubusercontent.com/u/741973?v=4)](https://github.com/beholdr "beholdr (1 commits)")[![hopkins385](https://avatars.githubusercontent.com/u/98618192?v=4)](https://github.com/hopkins385 "hopkins385 (1 commits)")[![angeljqv](https://avatars.githubusercontent.com/u/79208641?v=4)](https://github.com/angeljqv "angeljqv (1 commits)")[![richardkeep](https://avatars.githubusercontent.com/u/3874381?v=4)](https://github.com/richardkeep "richardkeep (1 commits)")[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (1 commits)")[![intrepidws](https://avatars.githubusercontent.com/u/125735?v=4)](https://github.com/intrepidws "intrepidws (1 commits)")

---

Tags

laravelphpspatieLaravel-Navigation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/spatie-laravel-navigation/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-navigation/health.svg)](https://phpackages.com/packages/spatie-laravel-navigation)
```

###  Alternatives

[spatie/laravel-package-tools

Tools for creating Laravel packages

945125.5M7.0k](/packages/spatie-laravel-package-tools)[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[spatie/macroable

A trait to dynamically add methods to a class

72759.6M64](/packages/spatie-macroable)[spatie/regex

A sane interface for php's built in preg\_\* functions

1.1k17.1M59](/packages/spatie-regex)[spatie/enum

PHP Enums

84529.1M68](/packages/spatie-enum)[spatie/laravel-collection-macros

A set of useful Laravel collection macros

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

PHPackages © 2026

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