ethanbarlo/livewiremesh
LivewireMesh integrates React components directly into Laravel Livewire using Livewire hooks (no Alpine intermediary). Get reactive props, two-way binding via useEntangle (live or deferred), and direct access to Livewire methods/properties with useWire.
useEntangle, useWire) for direct integration, eliminating the need for AlpineJS as a bridge. This reduces abstraction layers and improves performance by aligning with Livewire’s event-driven architecture.wire:model support for React components (e.g., custom selects, inputs) aligns with Livewire’s validation and state management, reducing boilerplate for complex forms.<livewire:react-select />), but their logic lives in React/TypeScript. This dual-responsibility pattern could complicate team workflows if frontend/backend teams are siloed.useEntangle<number>() require TypeScript adoption, which could be a blocker for PHP-first teams. Runtime type checking (e.g., via zod) could be a fallback.useErrorBag hook exposes Laravel validation errors to React, but cross-layer error propagation (e.g., Livewire flash messages vs. React state) may need custom handling.$emit or React’s useEffect?). The package’s debug logs (v0.5.5) help but may not cover all edge cases.composer require ethanbarlo/livewiremesh
npm install @livewiremesh/react # If using Vite
// app/Livewire/CustomSelect.php
class CustomSelect extends MeshComponent {
public function component() => 'resources/js/components/CustomSelect.tsx';
public function props() => ['options' => $this->options];
}
<!-- Before -->
<select x-model="selected" x-on:change="updateLivewire">
<!-- After -->
<livewire:custom-select :options="$options" wire:model="selected" />
@livewiremesh/react aligns with your React version.vite.config.js) to handle Mesh assets.php artisan vendor:publish --tag="livewiremesh-assets"
AppServiceProvider to initialize Mesh:
LivewireMesh::init();
useErrorBag hook simplifies error handling across layers.// vite.config.js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import livewire from '@livewiremesh/vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: ['resources/js/app.js'],
refresh: true,
}),
livewire({
components: ['resources/js/components/**/*.tsx'],
}),
],
});
@livewiremesh/react and Livewire must stay in sync. Use Dependabot to monitor updates.useEntangle could manifest as a Livewire or React issue. Example:
// React: Value not updating
const [value, setValue] = useEntangle<string>('user_name');
// Livewire: Property not binding
public $user_name;
MeshComponent traits).How can I help you explore Laravel packages today?