Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Laravel

Livewire Infinite Scroll Pattern

Implement infinite scroll loading with Livewire.

16 January 20261 min readLaravelاقرأ بالعربية

On this page

  1. Component
  2. View
  3. With Alpine Intersect

Infinite scroll:

Component

php
public int $perPage = 10;

public function loadMore()
{
    $this->perPage += 10;
}

#[Computed]
public function posts()
{
    return Post::latest()->take($this->perPage)->get();
}

View

blade
@foreach($this->posts as $post)
    <div>{{ $post->title }}</div>
@endforeach

<div x-intersect="$wire.loadMore()">
    <span wire:loading>Loading more...</span>
</div>

With Alpine Intersect

x-intersect.full="$wire.loadMore()"
All articles

Keep reading

  • Laravel Action Classes Pattern16 January 20261 min read
  • Laravel Action Classes: Single Responsibility16 January 20261 min read
  • Laravel API Rate Limiting16 January 20261 min read