laravel/livewire-starter-kit
Modern Laravel starter kit powered by Livewire 4 for reactive UIs in PHP. Includes TypeScript, Tailwind CSS, and Flux UI components, giving a solid foundation for building dynamic apps with Blade—without a JavaScript SPA framework.
Installation Clone the starter kit and install dependencies:
git clone https://github.com/laravel/livewire-starter-kit.git my-app
cd my-app
composer install
npm install
npm run dev
Run migrations and seeders:
php artisan migrate --seed
First Use Case: Creating a Livewire Component Generate a new Livewire component:
php artisan make:livewire Counter
Edit app/Http/Livewire/Counter.php and its corresponding Blade view (resources/views/livewire/counter.blade.php).
Use the component in a Blade template:
@livewire('counter')
Key Directories to Explore
app/Http/Livewire/ – Default Livewire components.resources/views/ – Blade templates (e.g., layouts/app.blade.php).resources/js/ – TypeScript/Flux UI integration.config/livewire.php – Livewire-specific configurations.Component-Based Development
// app/Http/Livewire/UserForm.php
public $name;
public $email;
public function save()
{
$this->validate([
'name' => 'required',
'email' => 'required|email',
]);
User::create($this->only(['name', 'email']));
}
<!-- resources/views/livewire/user-form.blade.php -->
<input wire:model="name" type="text">
<input wire:model="email" type="email">
<button wire:click="save">Save</button>
State Management
public properties for two-way binding and protected for internal state.protected $search = '';
public $results = [];
public function updatedSearch()
{
$this->results = User::where('name', 'like', '%'.$this->search.'%')->get();
}
Integration with Flux UI
<flux-button>, <flux-modal>) for pre-styled, accessible UI.<flux-modal wire:model="isOpen">
<flux-button wire:click="$set('isOpen', true)">Open Modal</flux-button>
<template #content>
<p>Modal content here.</p>
</template>
</flux-modal>
resources/js/).API-Driven Components
public function mount()
{
$this->posts = Post::latest()->take(10)->get();
}
public function loadMore()
{
$this->posts = Post::latest()->take(20)->get();
}
Authentication Flow
public function login()
{
$this->validate([
'email' => 'required|email',
'password' => 'required',
]);
if (auth()->attempt($this->only(['email', 'password']))) {
redirect('/dashboard');
}
}
TypeScript/Flux UI Setup
npm run dev or npm run build) after installing Flux UI components.npm run dev in watch mode during development.Livewire Property Binding
wire:model with non-public properties (Livewire only binds to public properties by default).public or use wire:model="property.name" for nested objects.Caching and Livewire
php artisan view:clear
Flux UI Template Slots
<flux-modal>
<template #header>...</template>
<template #content>...</template>
</flux-modal>
Livewire + Alpine.js Conflicts
wire:ignore on Alpine-managed elements or initialize Alpine after Livewire mounts:
<div wire:ignore x-data="{ open: false }">
<!-- Alpine logic -->
</div>
Livewire Logs
config/livewire.php:
'log' => env('LIVEWIRE_LOG', true),
storage/logs/livewire.log for component lifecycle events.Property Updates
dd($this->property) in updatedProperty() methods to debug reactive updates.Network Requests
X-Livewire headers).Custom Livewire Directives
php artisan vendor:publish --tag=livewire-config
app/Providers/AppServiceProvider.php:
Livewire::component('custom-directive', CustomDirective::class);
Flux UI Theming
tailwind.config.js:
module.exports = {
plugins: [
require('@flux-ui/tailwind'),
// Custom plugins
],
};
Livewire Middleware
HandleIncomingRequests:
public function handle(IncomingRequest $request)
{
if ($request->isLivewire()) {
$request->merge([
'middleware' => ['auth'],
]);
}
}
Testing Livewire
Livewire::test() in PHPUnit:
public function test_counter()
{
Livewire::test('counter')
->assertSee('Count: 0')
->call('increment')
->assertSee('Count: 1');
}
How can I help you explore Laravel packages today?