LivewireMesh is a powerful package that enables seamless integration of React components within Laravel Livewire applications. Inspired by MingleJS, LivewireMesh takes the concept further by building directly into Livewire's core functionality rather than relying on AlpineJS as an intermediary.
useEntangle hook to create bidirectional bindings between React state and Livewire propertiesuseWire hookYou can install the package via composer:
composer require ethanbarlo/livewiremesh
📖 For a complete setup guide, see INSTALL.md — covers Vite configuration, TypeScript setup, manual Livewire bundling, and creating your first Mesh component.
A full documentation and demo site is in the works.
LivewireMesh allows you to create React components that can be used as Livewire form inputs using wire:model. Here's how to create a custom React Select component that integrates seamlessly with Livewire:
Controlleruse Livewire\Component;
class UserProfile extends Component
{
public ?string $country = null;
public function save()
{
$this->validate([
'country' => 'required|string'
]);
}
public function countries(): array
{
return [
['value' => 'us', 'label' => 'United States'],
['value' => 'uk', 'label' => 'United Kingdom'],
['value' => 'ca', 'label' => 'Canada'],
];
}
public function render()
{
return view('livewire.user-profile');
}
}
View
<div>
<form wire:submit.prevent="save">
<div>
<label>Select your country:</label>
<livewire:react-select wire:model="country" :options="$this->countries()" />
@error('country')
<div class="text-red-500 text-sm mt-1">{{ $message }}</div>
@enderror
</div>
<button type="submit">Save</button>
</form>
</div>
Controller
use EthanBarlo\LivewireMesh\MeshComponent;
use Livewire\Attributes\Modelable;
class ReactSelect extends MeshComponent
{
#[Modelable]
public string $value = '';
public function __construct(
public array $options
) {}
public function component(): string
{
return 'resources/js/components/ReactSelect/index.ts';
}
public function props(): array
{
return [
'options' => $this->options,
];
}
}
View
import { useEntangle } from '@livewiremesh/react/contexts/LivewireContext';
import Select, { type SelectOption } from 'custom-select-component'; // Example
interface IReactSelect{
options: SelectOption[];
}
const ReactSelect: React.FC<IReactSelect> = ({ options }) => {
const [value, setValue] = useEntangle<string>('value');
return (
<Select value={value} onChange={setValue} options={options} />
);
}
This example demonstrates how LivewireMesh enables you to:
wire:modelPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
composer test
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.
How can I help you explore Laravel packages today?