PHPackages                             ralphjsmit/livewire-urls - 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. ralphjsmit/livewire-urls

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

ralphjsmit/livewire-urls
========================

Get the previous and current url in Livewire.

1.7.0(2mo ago)82270.3k—0%9[3 issues](https://github.com/ralphjsmit/livewire-urls/issues)[1 PRs](https://github.com/ralphjsmit/livewire-urls/pulls)3MITPHPPHP ^8.0CI passing

Since Jun 17Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/ralphjsmit/livewire-urls)[ Packagist](https://packagist.org/packages/ralphjsmit/livewire-urls)[ Docs](https://github.com/ralphjsmit/livewire-urls)[ RSS](/packages/ralphjsmit-livewire-urls/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (22)Versions (15)Used By (3)

[![livewire-urls](https://github.com/ralphjsmit/livewire-urls/raw/main/docs/images/livewire-urls.jpg)](https://github.com/ralphjsmit/livewire-urls/blob/main/docs/images/livewire-urls.jpg)

Get the current and previous url in Livewire.
=============================================

[](#get-the-current-and-previous-url-in-livewire)

This package gives you a simple way to **retrieve the current and previous URL** in Livewire.

Unfortunately, Laravel or Livewire **cannot handle** this for you, since Livewire also makes requests to your server when a user interacts with your webpage. This means that the usual methods like `URL()->current()` **point to an internal Livewire** route, instead of the **"real route" your user is on**.

This package provides you with a middleware and **helper methods to determine which URL is currently being used**.

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

[](#installation)

You can install the package via composer:

```
composer require ralphjsmit/livewire-urls
```

Next, you should add `\RalphJSmit\Livewire\Urls\Middleware\LivewireUrlsMiddleware::class,` to your Http `Kernel.php`, in the `web` key of the `$middlewareGroups` property.

Usage
-----

[](#usage)

### Current url

[](#current-url)

```
use RalphJSmit\Livewire\Urls\Facades\Url;

$currentUrl = Url::current();
```

### Current route

[](#current-route)

```
$currentRouteName = Url::currentRoute();
```

The `Url::currentRoute()` returns `null` when the user is on a route without a name.

### Previous url

[](#previous-url)

```
$previousUrl = Url::previous();
```

The `Url::previous()`-method returns `null` when there isn't a previous route available.

### Previous route

[](#previous-route)

```
$previousRouteName = Url::previousRoute();
```

The `Url::previousRoute()` returns `null` when there isn't a previous route or if the previous route wasn't a named route.

### Last recorded url

[](#last-recorded-url)

You can use the `Url::lastRecorded()` method to get the last url from the history that is *different* from the current url.

For example:

1. User visits page A
2. User visits page B
3. User visits page B

The `Url::lastRecorded()` would give you the url of page A. The function returns `null` when there isn't an other url found, apart from the current session.

```
$lastRecordedUrl = Url::lastRecorded();
```

### Last recorded route

[](#last-recorded-route)

You can use the `Url::lastRecordedRoute()` method to get the last route from the history that is *different* from the current url/route.

```
$lastRecordedRoute = Url::lastRecordedRoute();
```

The `Url::lastRecordedRoute()` would give you the route of page A from the previous example, **if page A is on a named route**. Otherwise, it would return `null`. The function also returns `null` when there isn't an other url found, apart from the current session.

General
-------

[](#general)

🐞 If you spot a bug, please submit a detailed issue and I'll try to fix it as soon as possible.

🔐 If you discover a vulnerability, please review [our security policy](../../security/policy).

🙌 If you want to contribute, please submit a pull request. All PRs will be fully credited. If you're unsure whether I'd accept your idea, feel free to contact me!

🙋‍♂️ [Ralph J. Smit](https://ralphjsmit.com)

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance86

Actively maintained with recent releases

Popularity49

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 54.1% 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 ~124 days

Recently: every ~208 days

Total

12

Last Release

67d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/59207045?v=4)[Ralph J. Smit](/maintainers/ralphjsmit)[@ralphjsmit](https://github.com/ralphjsmit)

---

Top Contributors

[![ralphjsmit](https://avatars.githubusercontent.com/u/59207045?v=4)](https://github.com/ralphjsmit "ralphjsmit (40 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (17 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (11 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![nexxai](https://avatars.githubusercontent.com/u/4316564?v=4)](https://github.com/nexxai "nexxai (1 commits)")[![Orrison](https://avatars.githubusercontent.com/u/6799341?v=4)](https://github.com/Orrison "Orrison (1 commits)")[![l3aro](https://avatars.githubusercontent.com/u/25253808?v=4)](https://github.com/l3aro "l3aro (1 commits)")

---

Tags

laravelralphjsmitlivewire-urls

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/ralphjsmit-livewire-urls/health.svg)

```
[![Health](https://phpackages.com/badges/ralphjsmit-livewire-urls/health.svg)](https://phpackages.com/packages/ralphjsmit-livewire-urls)
```

###  Alternatives

[ralphjsmit/laravel-seo

A package to handle the SEO in any Laravel application, big or small.

841433.3k21](/packages/ralphjsmit-laravel-seo)[leandrocfe/filament-apex-charts

Apex Charts integration for Filament PHP.

4861.2M8](/packages/leandrocfe-filament-apex-charts)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[ralphjsmit/laravel-filament-components

A collection of reusable components for Filament.

10972.2k2](/packages/ralphjsmit-laravel-filament-components)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[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)
