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

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

spatie/laravel-pjax
===================

A pjax middleware for Laravel 5

2.5.0(5mo ago)511392.4k↑19.4%4711MITPHPPHP ^7.2|^8.0CI passing

Since Oct 16Pushed 2mo ago14 watchersCompare

[ Source](https://github.com/spatie/laravel-pjax)[ Packagist](https://packagist.org/packages/spatie/laravel-pjax)[ Docs](https://github.com/spatie/laravel-pjax)[ Fund](https://spatie.be/open-source/support-us)[ RSS](/packages/spatie-laravel-pjax/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (10)Versions (27)Used By (11)

A pjax middleware for Laravel
=============================

[](#a-pjax-middleware-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2d8575f81943fbbbc91280e38df2271b2673d35bb01dc57491e846782f8d0e79/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d706a61782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-pjax)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![GitHub Workflow Status](https://github.com/spatie/laravel-pjax/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-pjax/actions/workflows/run-tests.yml/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/1c20ffc2228a44522caaaf17ef467e479a255360e059cacacf1e75e6846d2f89/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d706a61782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-pjax)

[Pjax](https://github.com/defunkt/jquery-pjax) is a jQuery plugin that leverages ajax to speed up the loading time of your pages. It works by only fetching specific html fragments from the server, and client-side updating only happens on certain parts of the page.

The package provides a middleware that can return the response that the jQuery plugin expects.

There's a [Vue-PJAX Adapter](https://github.com/riverskies/vue-pjax-adapter) equivalent by @barnabaskecskes which doesn't require jQuery.

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).

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

[](#support-us)

[![](https://camo.githubusercontent.com/2ec9c779f2826478128581567bdd8a3aec3c5407bfb8b409d9d4e3abf7ae8bf6/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d706a61782e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-pjax)

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-pjax
```

Next you must add the `\Spatie\Pjax\Middleware\FilterIfPjax`-middleware to the kernel.

```
// app/Http/Kernel.php

...
protected $middleware = [
    ...
    \Spatie\Pjax\Middleware\FilterIfPjax::class,
];
```

Usage
-----

[](#usage)

The provided middleware provides [the behaviour that the pjax plugin expects of the server](https://github.com/defunkt/jquery-pjax#server-side):

> An X-PJAX request header is set to differentiate a pjax request from normal XHR requests. In this case, if the request is pjax, we skip the layout html and just render the inner contents of the container.

### Laravel cache busting tip

[](#laravel-cache-busting-tip)

When using Laravel Mix to manage your frontend cache busting, you can use it to your advantage to bust pjax's cache. Simply include the `mix` method as the content of the `x-pjax-version` meta tag:

```

```

Multiple files:

```

```

This way, anytime your frontend's cache gets busted, pjax's cache gets automatically busted as well!

Changelog
---------

[](#changelog)

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

Testing
-------

[](#testing)

```
$ composer test
```

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)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

The middleware in this package was originally written by [Jeffrey Way](https://twitter.com/jeffrey_way) for the [Laracasts](https://laracasts.com)-lesson on [pjax](https://laracasts.com/lessons/faster-page-loads-with-pjax). His original code can be found [in this repo on GitHub](https://github.com/laracasts/Pjax-and-Laravel).

License
-------

[](#license)

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

###  Health Score

65

—

FairBetter than 99% of packages

Maintenance78

Regular maintenance activity

Popularity56

Moderate usage in the ecosystem

Community37

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 61.2% 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 ~157 days

Recently: every ~262 days

Total

25

Last Release

175d ago

Major Versions

0.0.1 → 1.0.02015-10-16

1.3.2 → 2.0.02019-09-20

PHP version history (4 changes)0.0.1PHP &gt;=5.5.0

1.2.0PHP ^5.5.0|^7.0

2.0.0PHP ^7.2

2.1.2PHP ^7.2|^8.0

### Community

Maintainers

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

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (63 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (8 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (5 commits)")[![CupOfTea696](https://avatars.githubusercontent.com/u/7327050?v=4)](https://github.com/CupOfTea696 "CupOfTea696 (5 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (3 commits)")[![sfavorite](https://avatars.githubusercontent.com/u/11838181?v=4)](https://github.com/sfavorite "sfavorite (2 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (2 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![drbyte](https://avatars.githubusercontent.com/u/404472?v=4)](https://github.com/drbyte "drbyte (1 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (1 commits)")[![imacrayon](https://avatars.githubusercontent.com/u/3410149?v=4)](https://github.com/imacrayon "imacrayon (1 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (1 commits)")[![srmklive](https://avatars.githubusercontent.com/u/839335?v=4)](https://github.com/srmklive "srmklive (1 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (1 commits)")[![thunder87](https://avatars.githubusercontent.com/u/13064503?v=4)](https://github.com/thunder87 "thunder87 (1 commits)")[![waclaw66](https://avatars.githubusercontent.com/u/15554561?v=4)](https://github.com/waclaw66 "waclaw66 (1 commits)")[![askdkc](https://avatars.githubusercontent.com/u/7894265?v=4)](https://github.com/askdkc "askdkc (1 commits)")[![barisbora](https://avatars.githubusercontent.com/u/10472206?v=4)](https://github.com/barisbora "barisbora (1 commits)")[![barnabaskecskes](https://avatars.githubusercontent.com/u/3535449?v=4)](https://github.com/barnabaskecskes "barnabaskecskes (1 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (1 commits)")

---

Tags

javascriptlaravelperformancephppjaxspatiepjaxlaravel-pjax

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.7M3.4k](/packages/craftcms-cms)[spatie/laravel-export

Create a static site bundle from a Laravel app

679153.2k7](/packages/spatie-laravel-export)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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