shahabzebare/laravel-nova-turbo

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

Installs: 11

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/shahabzebare/laravel-nova-turbo

1.0.0 2026-01-23 23:52 UTC

This package is auto-updated.

Last update: 2026-01-23 23:57:29 UTC


README

Latest Version on Packagist Tests Total Downloads License

🚀 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

Benchmarks

Real-world performance comparison on a Nova installation with 100+ resources:

Metric Without Turbo With Turbo Improvement
Server Response Time 455.58 ms 186.00 ms 59% faster
Resources Loaded ~100 1-5 95% reduction
📊 Click to see benchmark screenshots

With Nova Turbo (186ms)

With Nova Turbo

Without Nova Turbo (455ms)

Without Nova Turbo

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'),
    ],

    // Auto-regenerate cache when Laravel's cache is cleared (e.g., during deployments)
    'regenerate_on_cache_clear' => true,
];

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

The cache is automatically regenerated when you run php artisan cache:clear during deployments (enabled by default via regenerate_on_cache_clear).

If you prefer manual control, add to your deployment script:

php artisan nova:turbo-cache

Typical deployment order:

php artisan config:cache
php artisan route:cache
php artisan cache:clear          # Auto-regenerates turbo cache
# OR manually: php artisan nova:turbo-cache

To disable automatic regeneration:

NOVA_TURBO_REGENERATE_ON_CLEAR=false

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 (with version tracking)
  3. On page load, only the needed resources are registered
  4. The cached metadata is sent to the frontend to prevent JavaScript errors
  5. Cache is automatically invalidated when the package is updated (version mismatch)

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