shahabzebare/laravel-nova-turbo

Turbocharge Laravel Nova by lazy loading resources. Dramatically improves performance for applications with 50+ resources.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/shahabzebare/laravel-nova-turbo

dev-main 2026-01-21 21:50 UTC

This package is auto-updated.

Last update: 2026-01-21 21:59:23 UTC


README

Latest Version on Packagist Total Downloads

🚀 Turbocharge Laravel Nova by lazy loading resources.

If you have 50+ resources, Nova can become slow because it loads and runs authorization checks for ALL resources on every page load. This package fixes that by only loading the resources needed for the current page.

The Problem

Nova's default behavior on every page load:

  • Registers all resources (e.g., 100 resources)
  • Runs authorizedToCreate() for each resource
  • Generates metadata for all resources

With Nova Turbo:

  • Only loads 1-5 resources per page (current resource + relationships)
  • Dramatically improves page load times

Installation

composer require shahabzebare/laravel-nova-turbo

Setup

Step 1: Add the trait to your NovaServiceProvider

<?php

namespace App\Providers;

use Laravel\Nova\NovaApplicationServiceProvider;
use Shahabzebare\NovaTurbo\Traits\TurboLoadsResources;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    use TurboLoadsResources;

    // ... rest of your provider
}

Step 2: Generate the cache

php artisan nova:turbo-cache

This creates a cache file at bootstrap/cache/nova-turbo.php.

Step 3 (Optional): Publish config

php artisan vendor:publish --tag=nova-turbo-config

Commands

# Generate/refresh cache
php artisan nova:turbo-cache

# Clear cache
php artisan nova:turbo-cache --clear

Configuration

// config/nova-turbo.php

return [
    // Skip lazy loading in local environment for development
    'auto_refresh_in_dev' => true,

    // Paths to scan for Nova resources
    'resource_paths' => [
        app_path('Nova'),
    ],
];

External Resources

If you have resources outside app/Nova (e.g., in modules), register them:

// In your AppServiceProvider or a module service provider
use Shahabzebare\NovaTurbo\NovaTurbo;

public function boot()
{
    NovaTurbo::resources([
        \Modules\Order\Nova\Order::class,
        \Modules\Customer\Nova\Customer::class,
    ]);
}

Then re-run php artisan nova:turbo-cache.

Deployment

Add to your deployment script:

php artisan nova:turbo-cache

Consider adding it after config:cache:

php artisan config:cache
php artisan route:cache
php artisan nova:turbo-cache

How It Works

  1. The artisan command scans all resources and their relationship fields
  2. It builds a dependency map and caches it as a PHP array file
  3. On page load, only the needed resources are registered
  4. The cached metadata is sent to the frontend to prevent JavaScript errors

Development Mode

By default, lazy loading is disabled in local environment (auto_refresh_in_dev = true). This means you can add/modify resources without running the cache command.

For production-like testing locally:

NOVA_TURBO_AUTO_REFRESH=false php artisan serve

License

MIT License. See LICENSE for details.

Credits