From 6f52495c4b3c70a06bb43a0899bc8edc2f6a0e3b Mon Sep 17 00:00:00 2001 From: Chase Miller Date: Fri, 1 May 2026 00:44:43 -0600 Subject: [PATCH] Document Livewire 3 vs Livewire 4 component formats in dual-render docs --- docs/advanced/livewire-widgets.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/advanced/livewire-widgets.md b/docs/advanced/livewire-widgets.md index 06f5c7d..e6c56e0 100644 --- a/docs/advanced/livewire-widgets.md +++ b/docs/advanced/livewire-widgets.md @@ -181,6 +181,22 @@ class LiveCounter extends Component ``` +#### Component format (Livewire 3 vs Livewire 4) + +The example above uses the **class-based** format -- a separate PHP class in `app/Livewire/` plus a Blade view in `resources/views/livewire/`. This is the only format Livewire 3 ships, and the format Layup's documentation assumes. + +Livewire 4 adds two more formats and `php artisan make:livewire` defaults to single-file components, **not** the class-based layout: + +| Flag | Output | Notes | +|---|---|---| +| `--class` | `app/Livewire/Foo.php` + `resources/views/livewire/foo.blade.php` | Matches the example above. Pass this flag in Livewire 4 if you want the two-file layout. | +| `--sfc` (default in v4) | `resources/views/components/⚡foo.blade.php` | Single file with `` and the template inline. | +| `--mfc` | `resources/views/components/foo/{foo.blade.php, foo.php, foo.js, foo.css}` | One directory per component. | + +All three formats work with `BaseLivewireWidget`. `` only requires that the alias or class name resolves to a registered Livewire component; it doesn't care how the component is authored. Pick the format that matches the rest of your project. + +If you run `php artisan make:livewire LiveCounter` in a Livewire 4 project and got an SFC by mistake, either delete it and pass `--class`, or use the SFC as-is and reference it by its kebab-case alias from `getLivewireComponent()`. + Register the widget like any other: ```php