- What is yajra/laravel-datatables-html used for?
- It is a plugin for Laravel DataTables that generates DataTables JavaScript configuration using PHP instead of hand-written JS. It provides a fluent builder API for defining columns, buttons, and table options so table definitions can live in controllers or dedicated builder classes. The package only generates configuration; the DataTables JavaScript library still drives runtime behavior in the browser.
- How do I install yajra/laravel-datatables-html in Laravel?
- Install it with Composer, for example composer require yajra/laravel-datatables-html:^13, matching the package major to your Laravel major. It requires yajra/laravel-datatables to already be present, so add and validate both packages together if you are not already using Laravel DataTables. When your app uses Vite, call Builder::useVite() in AppServiceProvider so the default JavaScript type is set to module. Publishing assets is optional depending on your setup.
- Which package version supports my Laravel version?
- The compatibility matrix maps Laravel 8.x and below to package 4.x, then Laravel 9.x to 9.x, 10.x to 10.x, 11.x to 11.x, 12.x to 12.x, and 13.x to 13.x. Pin the package version in composer.json and test each Laravel upgrade explicitly rather than relying on automatic resolution. Also validate the DataTables JS and CSS versions used by your frontend build.
- How do I use the DataTables HTML builder with Vite?
- Call Builder::useVite() in your AppServiceProvider boot method to set the default JavaScript type to module. The package supports Vite, but you should verify DataTables, Buttons, and Select asset versions and initialization against your exact Vite pipeline. Keep an eye on asset loading order, since DataTables extensions version independently from the PHP package.
- Does laravel-datatables-html work with Livewire?
- Livewire support is part of the package's recent compatibility signals, so it can work in Livewire apps that need reactive tables. Verify Livewire 4 compatibility and table re-render behavior against the exact Laravel and Livewire versions in your application. For SPA or headless frontends, this HTML builder is a weak fit because your frontend framework owns the table UI.
- Do I still need yajra/laravel-datatables installed to use this package?
- Yes. This plugin is not an independent table engine or data provider, so it does not replace the server-side processing and data endpoint layer. Laravel DataTables handles the querying and response side, while this package generates the client-side configuration. If Laravel DataTables is not already installed, add both and validate them together.
- How do I add export buttons, column visibility, or bulk actions with the builder?
- Use the builder's fluent API to define buttons and columns in PHP, then let the generated script initialize DataTables with those options. Buttons, Select, and Editor extensions ship as separate assets with their own versions, and Editor or Buttons licensing should be reviewed before rollout. Advanced or unsupported DataTables options may still require raw JavaScript or script injection as an escape hatch.
- Is it safe to hide columns with the DataTables HTML builder?
- No. Column and button visibility configured in the builder is presentation only, so generated HTML and JavaScript can leak data if authorization is enforced only there. Enforce row and column access in policies and queries, and use the builder purely for display. Also validate escaping and any raw column content or script injection you add.
- Can I use laravel-datatables-html in an API-only or React/Vue application?
- It is a poor fit for API-only or headless products and for table UIs owned by React or Vue. In those cases, expose API resources and use your frontend's table library instead of an HTML and JavaScript builder. This package is designed for Laravel Blade admin panels, internal CRMs, and reporting screens using Vite or Livewire.
- What are the alternatives if laravel-datatables-html is not maintained?
- The fallback path is raw DataTables configuration in JavaScript, custom Blade partials, or switching to a different table library. This is a community, MIT-licensed convenience dependency with active releases but limited dependent metadata, so it is not a strategic platform bet. Keep your PHP builder definitions thin and document a raw-JS escape hatch so migration stays manageable.