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

madprabh's avatar

Component version missing in inertia jetstream application

Hey Folks,

I am having a problem in my application where the version of every component is returning null in my jetstream inertia application. This is causing erratic behavior on the browser every time I update the application since it doesn't automatically download the latest js files, forcing the users to do a manual browser refresh.

 "url": "/projects",
  "version": ""

Anyone any ideas what might be wrong?

0 likes
9 replies
madprabh's avatar

@MohamedTammam

This is my HandleInertiaRequests.php middleware

<?php

namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Inertia\Middleware;

class HandleInertiaRequests extends Middleware
{
    /**
     * The root template that's loaded on the first page visit.
     *
     * @see https://inertiajs.com/server-side-setup#root-template
     * @var string
     */
    protected $rootView = 'app';

    /**
     * Determines the current asset version.
     *
     * @see https://inertiajs.com/asset-versioning
     * @param  \Illuminate\Http\Request  $request
     * @return string|null
     */
    public function version(Request $request): ?string
    {
        return parent::version($request);
    }

    /**
     * Defines the props that are shared by default.
     *
     * @see https://inertiajs.com/shared-data
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function share(Request $request): array
    {
        return array_merge(parent::share($request), [
            //
            'previous_url' => url()->previous(),
        ]);
    }
}

You see anything missing?

madprabh's avatar

The strange thing is it started happening in the later versions of the jetstream application.

these are my versions for the current application

"inertiajs/inertia-laravel": "^0.5.2",
"laravel/framework": "^9.19", 
"laravel/jetstream": "^2.10",

The previous versions where it used to work

"inertiajs/inertia-laravel": "^0.4.3",
"laravel/framework": "^8.65",
"laravel/jetstream": "^2.4",

Don't know where its different.

madprabh's avatar

Yeah, its there

 "tightenco/ziggy": "^1.0"
shaungbhone's avatar

@madprabh In my project, Here is

"inertiajs/inertia-laravel": "^0.6.3",

HandleInertiaRequests.php

public function share(Request $request)
    {
        return array_merge(parent::share($request), [
            'ziggy' => function () use ($request) {
                return array_merge((new Ziggy)->toArray(), [
                    'location' => $request->url(),
                ]);
            },
        ]);
    }
madprabh's avatar

@shaungbhone By any chance is your ASSET_URL set to anything in your .env file?

I see that when I set this it does return the version, but it doesn't seem like the version changes on Asset compilation. I am checking this further

madprabh's avatar

I did that and get the version but it doesn't change unfortunately which causes the browser to not download any changed js causing the same erratic behavior.

I am now exploring this

https://laravel-vite.dev/guide/extra-topics/inertia.html#asset-versioning

// app/Http/Middleware/HandleInertiaRequests.php
public function version(Request $request): ?string
{
    return vite()->getHash();
}

When I use this though it throws and error

Call to undefined function App\Http\Middleware\vite()

Please or to participate in this conversation.