PHPackages                             audunru/version-warning - 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. audunru/version-warning

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

audunru/version-warning
=======================

Warn SPA users when they are using an outdated client

v4.0.0(1mo ago)02.8k↑16.7%MITPHPPHP ^8.3CI passing

Since Nov 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/audunru/version-warning)[ Packagist](https://packagist.org/packages/audunru/version-warning)[ RSS](/packages/audunru-version-warning/feed)WikiDiscussions main Synced 1mo ago

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

Warn SPA users when client is outdated compared to server
=========================================================

[](#warn-spa-users-when-client-is-outdated-compared-to-server)

[![Build Status](https://github.com/audunru/version-warning/actions/workflows/validate.yml/badge.svg)](https://github.com/audunru/version-warning/actions/workflows/validate.yml)[![Coverage Status](https://camo.githubusercontent.com/88c38a221e12f39784781cf3c664c9bf235d17a7850ddc25941cbfc029a02fe1/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f617564756e72752f76657273696f6e2d7761726e696e672f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/audunru/version-warning?branch=main)

Laravel middleware to help you notify users who are using an outdated version of the SPA client.

When you deploy a new version of your SPA to your server, not all users will start using the new version immediately. Anyone who is already logged in and does not refresh the page, will continue to use the old client until they close the browser tab or refresh the page. This package is meant to help you notify users with an outdated client that they should reload in order to use the latest version.

Currently, the package gets its version info from a `package.json` file in the root folder. This means that you will have to update the version in the package.json file whenever you make a change that requires all clients to update.

Installation
============

[](#installation)

Step 1: Install with Composer
-----------------------------

[](#step-1-install-with-composer)

```
composer require audunru/version-warning
```

Step 2: Add middleware to your routes
-------------------------------------

[](#step-2-add-middleware-to-your-routes)

Add the `VersionWarning` middleware to your API routes:

```
'api' => [
    'throttle:api',
    \Illuminate\Routing\Middleware\SubstituteBindings::class,
    \audunru\VersionWarning\Middleware\VersionWarning::class,
],
```

Step 3: Notify user when client is outdated
-------------------------------------------

[](#step-3-notify-user-when-client-is-outdated)

### Alternative A: Compare X-App-Version header client side

[](#alternative-a-compare-x-app-version-header-client-side)

When you make a fetch request to the server, add a `X-App-Version` header with a value of the client's current version. E.g.: `X-App-Version: 1.18.1`.

The `VersionWarning` middleware will compare the client version to the server version, and add a header called `X-Version-Warning` to the response if the versions do not match.

On the client side, you should check for the presence of the `X-Version-Warning` header. If it is present, the user should be notified that a reload is necessary so that the latest client assets (JavaScript and CSS) can be loaded.

### Alternative B: Compare X-App-Version header client side

[](#alternative-b-compare-x-app-version-header-client-side)

The `VersionWarning` middleware adds a header called `X-App-Version` to the response. On the client side, you can compare this version to the client version and notify the user in case of a mismatch.

Which version is the client running?
------------------------------------

[](#which-version-is-the-client-running)

### Set client version during build

[](#set-client-version-during-build)

If you're using Laravel Mix, you can include the current version during build time.

Set the MIX\_VERSION environment variable in your build script (you should install the [cross-var](https://www.npmjs.com/package/cross-var) and [cross-env](https://www.npmjs.com/package/cross-env) packages so that this works on both Mac/Windows):

```
"production": "cross-var cross-env MIX_VERSION=$npm_package_version mix --production",
```

You can then use `process.env.MIX_VERSION` in your frontend code.

### Get client version from HTML meta tag

[](#get-client-version-from-html-meta-tag)

Add the following to your layout blade template:

```

```

In your frontend code, read the value of this meta tag.

Configuration
=============

[](#configuration)

Publish the configuration file by running:

```
php artisan vendor:publish --tag=version-warning-config
```

Development
===========

[](#development)

Testing
-------

[](#testing)

Run tests:

```
composer test
```

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance90

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor2

2 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 ~68 days

Recently: every ~43 days

Total

24

Last Release

55d ago

Major Versions

v0.4.0 → v1.0.02023-07-18

v1.0.1 → v2.0.02024-04-07

v2.1.8 → v3.0.02025-03-16

v3.0.5 → v13.x-dev2026-03-24

PHP version history (4 changes)v0.1.0PHP ^8.0

v1.0.0PHP ^8.1

v2.0.0PHP ^8.2

v13.x-devPHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/444043228e007e4f695d18a30380b811fb60077138f7c46f111f45a1b98e2f1c?d=identicon)[audunru](/maintainers/audunru)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (50 commits)")[![audunru](https://avatars.githubusercontent.com/u/5163790?v=4)](https://github.com/audunru "audunru (40 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (15 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (2 commits)")

---

Tags

laravelSPA

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/audunru-version-warning/health.svg)

```
[![Health](https://phpackages.com/badges/audunru-version-warning/health.svg)](https://phpackages.com/packages/audunru-version-warning)
```

###  Alternatives

[cretueusebiu/laravel-vue-spa

A Laravel-Vue SPA starter project template.

3.0k18.8k](/packages/cretueusebiu-laravel-vue-spa)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

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