Skip to content

Allows you to embed any Livewire component on any website.

License

Notifications You must be signed in to change notification settings

karsonenns/livewire-embed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wire Extender

Wire Extender

Total Downloads Latest Stable Version License

Embed Livewire Components Anywhere

Wire Extender allows you to embed any Livewire component on any website or even within a static HTML file. Imagine embedding your Livewire-powered forms, chat widgets, or any other interactive components across different web platforms!

Quick Demo

Create a new HTML file on your local machine with the following contents to get a Livewire-powered click counter:

<html>
<head>
    <script src="https://unpkg.com/@wire-elements/wire-extender" data-uri="https://wire-elements.dev"></script>
</head>
<body>
    <livewire data-component="counter" data-params='{"count":10}'></livewire>
</body>
</html>

Installation

Note: Wire Extender is currently in development. Pull requests and feedback are welcome! 😄

  1. Require the package via Composer:

    composer require wire-elements/wire-extender
  2. Configure CSRF token verification:

    • For Livewire 10, open app/Http/Middleware/VerifyCsrfToken.php and add the IgnoreForWireExtender trait.
    • For Livewire 11, create a new middleware and replace the default one. (See full documentation for details)
  3. Adjust CORS settings:

    Open config/cors.php and add livewire/* to the paths array.

Creating an Embeddable Component

Add the #[Embeddable] attribute to your Livewire component class:

use WireElements\WireExtender\Attributes\Embeddable;

#[Embeddable]
class Counter extends Component
{
    // Your component logic here
}

Embedding a Component

  1. Publish the wire-extender.js library:

    php artisan vendor:publish --tag=wire-extender
  2. Include the script on the website where you want to embed your Livewire component:

    <script src="//your-domain.com/vendor/wire-elements/wire-extender.js"></script>
  3. Define the component you want to embed:

    <livewire data-component="counter" data-params='{"count":10}'>
      <!-- Placeholder... -->
    </livewire>

Advanced Configuration

  • Custom asset URLs
  • CDN usage
  • Placeholder content

For more details on these advanced topics, please refer to the full documentation.

Contributing

We welcome contributions! Please feel free to submit pull requests or open issues on our GitHub repository.

License

Wire Extender is open-sourced software licensed under the MIT license.

About

Allows you to embed any Livewire component on any website.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published