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

danyelkeddah's avatar

Why Laravel Nova 4.x using normal API Requests instead of partial reloads in InertiaJS

Wasn't it better to use Inertia partial reloading instead of normal api requests in Laravel Nova 4.0 ?

0 likes
2 replies
danyelkeddah's avatar

@martinbean Currently Laravel nova 4.x load the basic resource meta data via InertiaJS passing them to the page components, and after that on mounted hook (VueJS Nova JS) hit multiple API endpoints to start getting data, (resources, counts, authorization, lenses, tools, etc..) which means more api routes, controllers, requests and resources spent on it,

why not to use Lazy data evaluation, if the page can't be handled in one (initial request), then we can hit same route to load related data something like this

    public function __invoke()
    {
        return [
            'resources' => User::paginate(),
            'lenses' => Inertia::lazy(fn() => $this->loadLenses()),
            'actions' => Inertia::lazy(fn() => $this->loadActions()),
            'metrics' => Inertia::lazy(fn() => $this->loadMetrics()),
        ];
    }

Then on JS side

Inertia.reload({ only: ['lenses', 'actions',/*etc...*/] })
1 like

Please or to participate in this conversation.