Bagisto Hosting

How to use Pagination in Laravel?

Updated 19 June 2026

Laravel pagination makes it easy to manage large datasets by splitting records into smaller, organized pages instead of displaying everything at once.

Laravel provides built in methods like paginate(), simplePaginate(), and cursorPaginate() that you can use directly in your controller.

These methods let you control how many records are shown on each page and make navigation easy for users.

By using Laravel pagination, you can build faster, cleaner, and more user friendly web applications.

How Pagination Works in Laravel?

The pagination process has two main steps:

This approach improves performance and reduces page load time.

In this section, we will learn how to implement pagination in Laravel step by step.

Step 1: Query the Database

Suppose you have a StudentController and want to display student records with pagination.

You can use Laravel’s paginate() method to show a limited number of records per page and add navigation links for easy browsing.

paginate(10) means 10 records per page.

Step 2: Display the Paginated Data

Create an index.blade.php file to show student records.

The links() method automatically creates pagination links based on the current page and total number of records.

By default, Laravel uses Tailwind CSS for pagination. If your project uses Bootstrap, you can switch Laravel to use Bootstrap pagination styles.

Enable Bootstrap Pagination

Add the following code to AppServiceProvider.php:

Result:Result

Using Simple Pagination

The paginate() method counts the total number of records before fetching data.

This helps Laravel show page numbers and the total number of pages.

If you only need Previous and Next buttons, use simplePaginate().

It avoids counting all records and can perform better with large datasets.

Result:Result

Types of Pagination in Laravel

Laravel provides three main pagination methods to handle large data easily.

1. Pagination

The paginate() method gets records and also counts the total number of results.

It is useful when you want full page navigation with page numbers.

Features:

$studentData = Student::paginate(10);

2. Simple Pagination

The simplePaginate() method shows only Previous and Next links.

It is best when you do not need page numbers and want faster performance.

Best for:

$studentData = Student::paginate(10);

3. Cursor Pagination

The cursorPaginate() method is the fastest pagination method in Laravel.

Instead of page numbers, it uses a cursor to find the next records.

Best for:

$studentData = Student::cursorPaginate(10);

It returns:

Illuminate\Pagination\CursorPaginator

The cursor keeps the current position in the data. It helps Laravel load the next set of records quickly.

This makes it faster and more efficient for handling large amounts of data.

Which Pagination Method Should You Use?

Method Best For
paginate() When you need page numbers and total pages
simplePaginate() When you only need Previous and Next links
cursorPaginate() For large datasets and infinite scrolling applications

Conclusion

Laravel provides different pagination methods for different needs.

You can use full page navigation, simple previous/next links, or fast pagination for large datasets.

Choose the method that best fits your application’s needs and performance goals.

You can also hire Laravel developers for custom solutions or explore our extensions to improve your application.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project




    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home