How to Get Current URL in Laravel Blade Template?

I need to find the current URL within a Blade template. I want to use this URL in JavaScript. Can anyone guide me on how to achieve this in Laravel Blade?

In Laravel Blade templates, you can easily retrieve the current URL using the url() helper function. Here’s how you can do it:

<a href="{{url()->current()}}">Current Page</a>

Or for JavaScript

<script type="text/javascript">
    var currentPage = "{{url()->current()}}";

This line of code will output the current URL.