Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Livewire Datatables Laravel Package

abisetra/livewire-datatables

A Laravel Livewire package for building interactive data tables with sorting, searching, and pagination in your Blade views. It aims to keep table setup simple and reactive without leaving the Livewire component model.

View on GitHub
Deep Wiki
Context7

Getting Started

This package brings DataTables-style grids into Livewire. It has no meaningful release history since 1.0.0 in mid-2023 and almost no community footprint, so treat the README and source as the spec and verify against your stack before committing.

Minimal steps:

  1. Confirm your stack matches the package’s requirements — Laravel, Livewire (check whether 2.x or 3.x), Tailwind CSS, and Alpine.js. The description explicitly targets this trio; mismatched Livewire versions are the most common install failure.
  2. Install:
    composer require abisetra/livewire-datatables
    
  3. Publish any provided config, views, or assets:
    php artisan vendor:publish --provider="Abisetra\LivewireDatatables\LivewireDatatablesServiceProvider"
    
    (Confirm the provider FQN in bootstrap/cache/packages.php after install.)
  4. Ensure Tailwind scans the package’s Blade views — add the vendor view path to tailwind.config.js content[], or safelist the classes it emits.
  5. Load Alpine via Livewire if you don’t already; the package assumes Alpine is available for dropdowns, column toggles, and similar interactions.

First use case — a single table backed by an Eloquent query:

  1. Read the README’s usage example first; that is your source of truth for the component/column API surface.
  2. Create one Livewire component per table (e.g., App\Http\Livewire\UsersTable).
  3. Define columns in the component: field/key, label, sortable, searchable, and any formatter or Blade view.
  4. Return the base query from the component (typically the full query, not a pre-paginated one — the package handles pagination).
  5. Render it in a Blade view: <livewire:users-table />.
  6. Hit the page, sort a column, type in the search, change page — confirm each works before customizing.

Where to look first:

  • README usage examples and the sample component (if shipped)
  • The package’s column/base component classes — these define the actual contract
  • Any published config for defaults (pagination size, search delay, etc.)
  • The published Blade views — this is where Tailwind/Alpine coupling lives

Implementation Patterns

  • One component per table. Don’t try to serve multiple tables from one Livewire component; it makes state (search, sort, page) ambiguous and breaks reactivity.
  • Base query, not result set. Return the Eloquent Builder (or query builder) and let the package apply search/sort/pagination. If you pre-->get(), you lose server-side processing and will load the whole table into memory.
  • Eager-load relations up front. Columns backed by relations (user.department.name) will N+1 unless you ->with([...]) in the base query. This is where most “the table is slow” complaints originate.
  • Declare sortable/searchable explicitly. Default to a whitelist rather than allowing arbitrary column sorting — it protects against SQL injection via user-supplied sort fields and avoids sorting on unindexed/JSON columns.
  • Custom cell rendering via Blade views. For badges, links, formatted dates, or action buttons, use the package’s per-column view hook rather than embedding HTML strings in PHP. This keeps Tailwind classes in files Tailwind can scan.
  • Actions column as a callback or view. For row-level actions (edit/view/delete), prefer emitting Livewire events from the view, e.g. wire:click="delete({{ $row->id }})", so the parent component owns the side effect.
  • Reactive updates. Since the package hooks into the Livewire lifecycle, mutations made elsewhere on the page should propagate. Pattern: dispatch a Livewire event from another component (e.g., $this->dispatch('user-updated')) and have the table listen, or rely on the parent component re-rendering the table.
  • Search + debounce. If the package doesn’t debounce, add a wire:model.debounce.400ms binding on the search input. Avoid server round-trips on every keystroke.
  • Query string for state. Bind page, sort, and search to $queryString on the component so URLs are shareable and browser back works — a common expectation users bring from DataTables.

Typical component skeleton:

// app/Http/Livewire/UsersTable.php
class UsersTable extends Component
{
    use WithPagination;

    protected $queryString = ['search' => ['except' => ''], 'sort', 'direction'];

    public string $search = '';
    public string $sort = 'created_at';
    public string $direction = 'desc';

    public function render()
    {
        return view('livewire.users-table');
    }
}

Keep the query and column definitions in the component; keep presentation in a Blade file. That separation makes the table testable with Livewire::test(), where you can assert rendered rows, sorting behavior, and search filtering.

Gotchas and Tips

  • Very low maintenance signal — plan for it. Zero stars and a last release from June 2023 means the README is likely already drifting from the code. Pin the version in composer.json ("abisetra/livewire-datatables": "1.0.0") rather than ^1.0, and be ready to fork. Check the repository for open issues and the last commit date before adopting.
  • Livewire version is the biggest compatibility hazard. Livewire 2 → 3 introduced breaking changes to lifecycle hooks, dispatch, and pagination traits. Verify which v2/v3 the package targets; the 1.0.0 “Fixed Laravel compatability” note refers to Laravel, not Livewire. Mismatches typically show as silent non-updating tables or pagination errors.
  • Tailwind purge will strip dynamic classes. Any class string built at runtime ("bg-{$color}-500") won’t appear in your compiled CSS. Either add the package’s vendor views to tailwind.config.js content or use fixed class maps. Symptom: table renders but badges/buttons are unstyled.
  • Alpine must be present and initialized once. If you use Livewire 3 with @livewireScripts, Alpine ships with it; with Livewire 2 you may need @livewireScripts + alpinejs separately. Double-loading Alpine breaks dropdowns and column visibility toggles.
  • Watch for N+1 in search/sort. Sorting or searching on a relation forces a join; if it silently switches to in-memory filtering you’ll see memory spikes on large tables. Use ->with() and consider adding explicit join-based sortable columns.
  • Sortable/searchable on non-indexed columns is a footgun. LIKE '%term%' search on large tables with no index will time out. For real workloads, limit searchable columns or push to a dedicated search index.
  • Pagination and page reset. When search or sort changes, call $this->resetPage(). Otherwise users see “empty page 3” after narrowing results — a very common report.
  • Don’t edit vendor views. Publish and version-control them. vendor:publish --force will silently overwrite your customizations; diff before forcing.
  • Clear caches after publishing/upgrading:
    php artisan config:clear
    php artisan view:clear
    composer dump-autoload
    
    Blade view caching is specifically relevant because the package ships views; stale compiled views after a publish are a classic “my change didn’t take” cause.
  • Debugging tip. Use Livewire’s $this->dispatch() events and Laravel Telescope’s Livewire panel to inspect queries and lifecycle runs per interaction. dd() inside the package’s render path kills the Livewire request and makes debugging harder than logging around your own base query.
  • Extension points to try before forking. Published config (default page size, search debounce), published Blade views, subclassing the base table/column classes, and Livewire public properties are the intended seams. Only fork if you need to change query-building or lifecycle internals.
  • Test it. Write at least one feature test that renders the table, changes search, and changes sort, asserting the result set changes. Given the package’s age and low activity, this test is your regression guard against a future dependency bump silently breaking behavior.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect