Hello Devs,

In this tutorial, we are going to learn how to create search with pagination livewire laravel.

Follow this step by step guide given below:

Step 1 : 

Install Laravel 7

composer create-project --prefer-dist laravel/laravel blog

Step 2 : 

Seed Database

public function run()

Step 3 :

 Create Component

php artisan make:livewire search



namespace App\Http\Livewire;

use Livewire\Component;
use Livewire\WithPagination;
use App\User;

class Search extends Component
    use WithPagination;
    public $searchTerm;

    public function render()
        $searchTerm = '%'.$this->searchTerm.'%';
        return view('livewire.search',[
            'users' => User::where('name','like', $searchTerm)->paginate(10)


<div class="container">
    <div class="row">
        <div class="col-md-12">
            <input type="text"  class="form-control" placeholder="Search" wire:model="searchTerm" />

            <table class="table table-bordered" style="margin: 10px 0 10px 0;">
                @foreach($users as $user)
                        {{ $user->name }}
                        {{ $user->email }}
            {{ $users->links() }}

Step 4 : 

Create Route routes/web.php

Route::get('/search-box', function () {
    return view('searchbox');

Step 5 :

 Create View File resources/views/searchbox.blade.php

<!DOCTYPE html>
    <link rel="stylesheet" href="{{ asset('css/app.css') }}">
<div class="container mt-4">
    <div class="row">
      <div class="col-md-8 offset-2">
        <div class="card">
          <div class="card-header bg-success text-white ">
            <strong>Search with Laravel Livewire - Nicesnippets.com</strong>
          <div class="card-body">
<script src="{{ asset('js/app.js') }}"></script>

Run this command:

php artisan serve

Open this URL:


I hope this example helps you.