Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

madprabh's avatar

Is there a way to use url()->previous() in Jetstream+inertia vue file

Hey folks

I am trying to implement a simple back navigation button using "url()->previous()" in my Jetstream+inertia application

<jet-nav-link :href="url()->previous()" class="inline-flex mr-3 text-gray-400 hover:text-gray-500">
                        <!-- Heroicon name: solid/thumb-up -->
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 -5 24 24" stroke="currentColor">
					<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16l-4-4m0 0l4-4m-4 4h18" />
				</svg>
                        
</jet-nav-link>

Does anyone know how to do this?

0 likes
1 reply
koramit's avatar
koramit
Best Answer
Level 9

@madprabh

I assume that you want to do this on the client side right ?

You can use inertia shared data https://inertiajs.com/shared-data

like this,

class HandleInertiaRequests extends Middleware
{
    public function share(Request $request)
    {
        return array_merge(parent::share($request), [

            'previous' => fn () => URL::previous(),

        ]);
    }
}

then the data will available in $page, example for vue 2

<jet-nav-link 
	:href="$page.props.previous"
    class="inline-flex mr-3 text-gray-400 hover:text-gray-500">

Please or to participate in this conversation.