How do i build a load more pagination using livewire

How to load more data with the click of a button when using laravel livewire for data pagination…
I don’t know how to go about this…
Any help is appreciated…

1 Like

I don’t know how efficient this is, but you can add a count property to your component and increase it by 5 or whatever when the button is clicked, and limit your query by count in the render method.

1 Like

Include use WithPagination; inside of the component class (add use Livewire/WithPagination; to the file itself if you don’t automatically pull it in your editor).

Add the paginate() method on your model you are passing into the view 'posts' => \App\Post::paginate($numPerPage) or however you pass it.

Use the default {{ $posts->links() }} laravel method, the WithPagination trait overrides it for livewire to use. If you don’t use the trait, it will still work, but you will get full page reloads on the links.

1 Like

You’ll have to post some code for us to see and work through, but in general the above comments should do it.

1 Like