How to implement / do "Load more" or "See more" in Laravel
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
# Mastering Dynamic Loading in Laravel: Implementing "Load More" Functionality
As a senior developer, I often encounter scenarios where we need to display large datasets to users without overwhelming them immediately. The concept of "Load More" or "See More" functionalityâwhere content dynamically appends itself upon user interactionâis crucial for improving user experience.
If you are currently using Laravel's standard `paginate()` method and find yourself struggling with how to append records dynamically, you are hitting a common architectural hurdle. While pagination is excellent for traditional navigation (Page 1, 2, 3), implementing infinite scrolling requires a slightly different approach involving state management on the backend and asynchronous requests on the frontend.
This guide will walk you through the cleanest, most robust way to implement "Load More" functionality in Laravel using Eloquent and basic AJAX principles.
## Why Standard Pagination Isn't Enough for "Load More"
When you use `$posts->paginate(10)`, Laravel handles the slicing of data perfectly. However, this method is designed to render links for subsequent pages. To achieve a true "Load More" effect where new data appears *without* a full page refresh, we need to manage the state of what has already been loaded and request only the next batch of records from the server upon a click event.
The best way to handle this is by moving away from simple pagination links and embracing **Offset-based Pagination** combined with an API endpoint that serves specific data chunks.
## Step 1: Preparing the Backend (Controller & Eloquent)
Instead of relying solely on `paginate()`, we will manage the starting point for our query using the `offset()` method. This allows us to tell the database exactly where to start fetching the next set of records.
Let's assume you want to load 10 records at a time, and store the current offset in your session or request parameters.
### Controller Implementation
We will create an endpoint that accepts an `offset` parameter and returns only the requested chunk of data.
```php
use App\Models\Post;
use Illuminate\Http\Request;
class PostController extends Controller
{
public function loadPosts(Request $request)
{
// Determine the offset. Default to 0 if not provided.
$offset = $request->input('offset', 0);
$perPage = 10; // Define how many items to load
// Fetch the posts using the offset method
$posts = Post::orderBy('created_at', 'DESC')
->offset($offset)
->take($perPage)
->get();
// Optionally, you could return the total count for UI purposes
$total = Post::count();
return response()->json([
'posts' => $posts,
'total' => $total,
]);
}
public function index()
{
// Initial load: Fetch the first batch
$posts = Post::orderBy('created_at', 'DESC')->take(10)->get();
return view('post.index', compact('posts'));
}
}
```
### Route Setup
Ensure you have a route defined to handle this request:
```php
Route::get('/posts/load', [PostController::class, 'loadPosts']);
```
## Step 2: Implementing the Frontend (View & JavaScript)
The view will display the initial set of posts and include a mechanism (a button) that triggers an AJAX call to load the next batch.
### View Implementation (`post.index`)
In your Blade file, you need a container for the posts and a button to trigger the loading.
```blade
