Seamless infinite scrolling for Laravel Nova 3, 4, and 5 resources with automatic loading, filtering, and theme support
iamgerwin/nova-infinite-scroll is a Laravel package for seamless infinite scrolling for laravel nova 3, 4, and 5 resources with automatic loading, filtering, and theme support.
It currently has 0 GitHub stars and 15 downloads on Packagist (latest version 1.0.0).
Install it with composer require iamgerwin/nova-infinite-scroll.
Discover more Laravel packages by iamgerwin
or browse all Laravel packages to compare alternatives.
Last updated
Seamless infinite scrolling for Laravel Nova resources. Automatically loads more records as users scroll, eliminating traditional pagination and providing a smooth, modern browsing experience. Compatible with Nova 3, 4, and 5.
Perfect for resources with many records where traditional pagination feels clunky. Works harmoniously with filters, search, and sorting β everything just works! β¨
Install the package via composer:
composer require iamgerwin/nova-infinite-scroll
Optionally, publish the configuration file:
php artisan vendor:publish --tag="nova-infinite-scroll-config"
The package automatically registers itself with Nova β no additional setup required!
Add the HasInfiniteScroll trait to your Nova Resource:
<?php
namespace App\Nova;
use Iamgerwin\NovaInfiniteScroll\Traits\HasInfiniteScroll;
use Laravel\Nova\Resource;
class User extends Resource
{
use HasInfiniteScroll;
// Your resource definition...
}
That's it! Your resource now supports infinite scrolling. π
The package includes sensible defaults, but you can customize everything via the config file:
return [
// Enable/disable infinite scroll globally (not recommended)
// Set to false to only enable for resources with HasInfiniteScroll trait
'enabled' => false,
// Number of records to load per batch
'per_page' => 25,
// Distance from bottom (in pixels) to trigger loading
'threshold' => 200,
// Customize loading messages
'loading_text' => 'Loading more records...',
'end_text' => 'All records loaded',
// Auto-enable on resource index pages with the trait
'auto_enable' => true,
// Exclude specific resources (when global enabled is true)
'excluded_resources' => [
// App\Nova\User::class,
],
];
Override settings for individual resources:
class Article extends Resource
{
use HasInfiniteScroll;
public static function infiniteScrollPerPage(): int
{
return 50; // Load 50 articles at a time
}
public static function infiniteScrollThreshold(): int
{
return 300; // Trigger loading 300px from bottom
}
public static function infiniteScrollEnabled(): bool
{
return auth()->user()->prefersInfiniteScroll ?? true;
}
}
Nova Infinite Scroll uses the Intersection Observer API to detect when users scroll near the bottom of the resource table. When triggered:
The magic happens behind the scenes with Vue.js components that integrate directly with Nova's resource index pages. Filters, search, and sorting automatically reset the infinite scroll state β no manual intervention needed!
public static function infiniteScrollEnabled(): bool
{
// Only for admins
return auth()->user()->isAdmin();
// Or based on resource count
// return static::newModel()->count() > 100;
}
public static function infiniteScrollPerPage(): int
{
// Smaller batches on mobile
if (request()->header('User-Agent') && str_contains(request()->header('User-Agent'), 'Mobile')) {
return 15;
}
return 30;
}
In your config/nova-infinite-scroll.php:
'excluded_resources' => [
\App\Nova\Resources\HeavyResource::class,
\App\Nova\Resources\RealtimeData::class,
],
HasInfiniteScroll trait is added to your Resourcenova-infinite-scroll.enabled is true in configexcluded_resourcesIf you're experiencing issues with default pagination (clicking "Next" does nothing), ensure you're using the latest version. Versions prior to 1.1.0 had a critical bug that broke pagination for resources without the trait.
php artisan nova:publishper_page value for fewer records per batchRun the test suite:
composer test
Run tests with coverage:
composer test-coverage
Check code style:
composer format
Run static analysis:
composer analyse
Please see CHANGELOG for more information on recent changes.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate and adhere to PSR-12 coding standards.
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
Made with β€οΈ for the Laravel Nova community