Reader Stacks

Getting the Current URL in a Laravel Blade File

url()->current(), request()->fullUrl(), and route()->currentRouteName() — the difference between the URL, the route name, and the query string, and when each one is the right check.

Getting the Current URL in a Laravel Blade File

Laravel gives you several ways to get "the current URL" in a Blade view — which one is correct depends on whether you actually need the path, the full URL with query string, or just the route's name to compare against.

URL without query string

{{ url()->current() }}
{{ request()->url() }}

Both return the current URL without any query parameters — useful for building a canonical link or comparing against a known path.

Full URL including query string

{{ request()->fullUrl() }}

Use this when the query string is actually part of what makes the "current URL" meaningful — a filtered listing page, for example, where ?category=shoes genuinely changes what page this is.

Just the path

{{ request()->path() }}

Returns the path relative to the domain, without the scheme or host — e.g. products/42, not https://example.com/products/42.

Comparing against the current route name — usually the better check

If the goal is "is this the active nav link," comparing against the route name is more robust than string-comparing URLs, since it doesn't break if the URL structure changes later:

<a href="{{ route('dashboard') }}" class="{{ request()->routeIs('dashboard') ? 'active' : '' }}">
    Dashboard
</a>

request()->routeIs() also supports wildcards — request()->routeIs('admin.*') matches any route name starting with admin., useful for highlighting a whole nav section as active rather than a single link.

Checking if the current path matches a pattern

@if (request()->is('admin/*'))
    <!-- admin section styling -->
@endif

request()->is() checks the path directly against a wildcard pattern — useful when there's no named route to compare against, but generally routeIs() is the more maintainable choice when a route name exists.

Topics: Developer Productivity