Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Livewire Async Select Laravel Package

drpshtiwan/livewire-async-select

View on GitHub
Deep Wiki
Context7

Livewire Async Select

A powerful async select component for Laravel Livewire with Alpine.js - a modern, lightweight alternative to Select2.

Latest Version GitHub Tests Action Status Total Downloads Code Style License

πŸŽ₯ Demo

Livewire Async Select Demo

▢️ Watch Full Demo on YouTube

✨ Features

  • πŸš€ Asynchronous Loading - Load options dynamically from API endpoints
  • πŸ” Search & Filter - Built-in search with debouncing
  • 🎯 Multiple Selection - Beautiful chip/tag display
  • ⚑ Alpine.js Powered - Lightweight, no jQuery dependency
  • 🎨 Styled with Tailwind CSS - Pre-built styles with las- prefix
  • 🎭 Custom Slots - Fully customizable rendering
  • πŸ“¦ Easy Integration - Native Livewire component
  • πŸ”„ Two-way Binding - Full wire:model support
  • πŸ”’ No Style Conflicts - All classes prefixed with las-
  • πŸ” Authentication Support - Custom headers and internal authentication
  • πŸ›‘οΈ Secure Internal Auth - Signed tokens with replay protection

πŸ“š Documentation

πŸ“– Full Documentation

Complete guides, examples, and API reference available at:

https://livewire-select.thejano.com/

To build and view the documentation locally, see DOCS.md.

⚑ Quick Install

  1. Install via Composer:
composer require drpshtiwan/livewire-async-select
  1. Publish the CSS assets:
php artisan vendor:publish --tag=async-select-assets
  1. Setup your layout (important!):
<head>
    @asyncSelectStyles
    {{-- Optional: only if using Bootstrap 4 theme styling --}}
    {{-- @asyncSelectBootstrapV4Styles --}}
    @livewireStyles
</head>
<body>
    {{ $slot }}
    
    @livewireScripts
    @stack('scripts')  {{-- Required! --}}
</body>

⚠️ Important: The @stack('scripts') directive is required for the component to work properly.

🎯 Basic Usage

<livewire:async-select
    name="user_id"
    wire:model="selectedUser"
    endpoint="/api/users/search"
    placeholder="Search users..."
/>

Custom Slots (Livewire 3.3+ / 4.x)

<livewire:async-select :options="$users" wire:model="selectedUser">
    <livewire:slot name="slot">
        <div>{{ $option['label'] }}</div>
    </livewire:slot>

    <livewire:slot name="selectedSlot">
        <strong>{{ $option['label'] }}</strong>
    </livewire:slot>
</livewire:async-select>

Slot variables are provided automatically:

  • option slot: $option, $isSelected, $isDisabled, $multiple
  • selected slot: $option

API Route with async-auth middleware:

// Default guard (web)
Route::middleware(['async-auth'])->get('/api/users/search', function (Request $request) {
    $users = User::where('name', 'like', "%{$request->get('search')}%")
        ->limit(20)
        ->get();
    
    return response()->json(['data' => $users]);
});

// With Sanctum
Route::middleware(['async-auth:sanctum'])->get('/api/users/search', function (Request $request) {
    // Works with Sanctum tokens or internal auth
    $users = User::where('name', 'like', "%{$request->get('search')}%")
        ->limit(20)
        ->get();
    
    return response()->json(['data' => $users]);
});

// With web guard and session persistence
Route::middleware(['web', 'async-auth:web,persist'])->get('/api/users/search', function (Request $request) {
    // Persists login in session
    $users = User::where('name', 'like', "%{$request->get('search')}%")
        ->limit(20)
        ->get();
    
    return response()->json(['data' => $users]);
});

The async-auth middleware is automatically registered and works exactly like auth middleware, but also handles internal authentication automatically when the X-Internal-User header is present. Supports all guards: async-auth:web, async-auth:sanctum, async-auth:api, etc.

β†’ View full documentation

πŸ“‹ Requirements

  • PHP 8.2+
  • Laravel 11.x, 12.x, or 13.x
  • Livewire 3.3+ or 4.x

πŸ†š Why This Package?

Feature Livewire Async Select Select2
jQuery Dependency ❌ No βœ… Yes
Livewire Integration βœ… Native ⚠️ Manual
Bundle Size 🟒 Small 🟑 Large
Modern Stack βœ… Yes ❌ Legacy

🀝 Contributing

Contributions are welcome! Please see the documentation for details.

πŸ“„ License

The MIT License (MIT). Please see License File for more information.

πŸ™ Credits

πŸ”— Links

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky