Docs Hub

🇮🇷
iran mirrors
LaravelLaravelLivewireLivewireAlpine.jsAlpine.jsNext.jsNext.jsVue.jsVue.jsZustandZustandNuxt.jsNuxt.jsFilamentFilament
BootstrapBootstrap
Nest.jsNest.js
ReactReact
Vite.jsVite.js
Tailwind CSSTailwind CSS

© 2026 Juza66 and Arash Fadaee

Docs Hub

🇮🇷 iran mirrorsActionsAGENTSAlpineAttribute AsyncAttribute ComputedAttribute DeferAttribute IsolateAttribute JsAttribute JsonAttribute LayoutAttribute LazyAttribute LockedAttribute ModelableAttribute OnAttribute ReactiveAttribute RenderlessAttribute SessionAttribute TitleAttribute TransitionAttribute UrlAttribute ValidateBest PracticesBlade ComponentsBundlingComponent HooksComponentsComputed PropertiesContribution GuideCspDirective IslandDirective PersistDirective PlaceholderDirective TeleportDirtyDownloadsEventsFormsHow Livewire WorksHydrationInstallationIslandsJavascriptLazyLifecycle HooksLoading StatesLockedMorphNavigateNestingOfflinePackagesPagesPaginationPollingPropertiesQuickstartRedirectingSecuritySession PropertiesStylesSynthesizersTeleportTestingThe Livewire ProtocolTroubleshootingUnderstanding NestingUndocumented Features TodoUpgrade Guide Scratch FileUpgradingUploadsUrlValidationVoltWire BindWire ClickWire CloakWire ConfirmWire CurrentWire DirtyWire IgnoreWire InitWire IntersectWire LoadingWire ModelWire NavigateWire OfflineWire PollWire RefWire ReplaceWire ShowWire SortWire StreamWire SubmitWire TextWire Transition
Docs Hub

Livewire is a Laravel package, so you will need to have a Laravel application up and running before you can install and use Livewire. If you need help setting up a new Laravel application, please see the official Laravel documentation.

Prerequisites

Before installing Livewire, make sure you have:

  • Laravel version 10 or later
  • PHP version 8.1 or later

Install Livewire

To install Livewire, open your terminal and navigate to your Laravel application directory, then run the following command:

shell
composer require livewire/livewire

That's it! Livewire uses Laravel's package auto-discovery, so no additional setup is required.

Ready to build your first component? Head over to the Quickstart guide to create your first Livewire component in minutes.

Create a layout file

When using Livewire components as full pages, you'll need a layout file. You can generate one using the Livewire command:

shell
php artisan livewire:layout

This creates a layout file at resources/views/layouts/app.blade.php with the following contents:

blade
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <title>{{ $title ?? config('app.name') }}</title>

        @vite(['resources/css/app.css', 'resources/js/app.js'])

        @livewireStyles
    </head>
    <body>
        {{ $slot }}

        @livewireScripts
    </body>
</html>

The @livewireStyles and @livewireScripts directives include the necessary JavaScript and CSS assets for Livewire to function. Livewire bundles Alpine.js with its JavaScript, so both are loaded together.

[!info] Asset injection is automatic Even without these directives, Livewire will automatically inject its assets into pages that contain Livewire components. However, including the directives gives you explicit control over where the assets are placed, which can be helpful for performance optimization or compatibility with other packages.

Publishing the configuration file

Livewire is "zero-config", meaning you can use it by following conventions without any additional configuration. However, if needed, you can publish and customize Livewire's configuration file:

shell
php artisan livewire:config

This will create a new livewire.php file in your Laravel application's config directory where you can customize various Livewire settings.

Troubleshooting

Livewire JavaScript not loading (404 error)

Symptom: Livewire's JavaScript file returns a 404 error, or Livewire features don't work.

Livewire serves its JavaScript from a hash-based endpoint like /livewire-{hash}/livewire.js, where {hash} is derived from your application's APP_KEY. This unique path varies per installation.

Common causes:

Nginx configuration blocking the route: If you're using Nginx with a custom configuration, it may be blocking Laravel's dynamic Livewire routes. You can either:

  • Configure Nginx to pass requests matching /livewire-*/ to Laravel (e.g., location ~ ^/livewire-[a-f0-9]+/ { try_files $uri $uri/ /index.php?$query_string; })
  • Manually bundle Livewire to avoid serving through Laravel
  • Publish Livewire's assets to serve them directly from your web server

Route caching: If you've run php artisan route:cache, Laravel may not recognize Livewire's routes. Clear the cache:

shell
php artisan route:clear

Missing @livewireScripts: If you've disabled automatic asset injection, ensure @livewireScripts is in your layout file before </body>.

Alpine.js not available on pages without Livewire components

Symptom: You want to use Alpine.js on a page that doesn't have any Livewire components.

Solution: Since Alpine is bundled with Livewire, you need to include @livewireScripts even on pages without Livewire components:

blade
<!DOCTYPE html>
<html>
    <head>
        @livewireStyles
    </head>
    <body>
        <!-- No Livewire components, but we want Alpine -->
        <div x-data="{ open: false }">
            <button @click="open = !open">Toggle</button>
        </div>

        @livewireScripts
    </body>
</html>

Alternatively, manually bundle Livewire and Alpine and import Alpine in your JavaScript.

Components not updating or errors in browser console

Check the following:

  • Ensure @livewireStyles is in the <head> of your layout
  • Ensure @livewireScripts is before </body> in your layout
  • Check your browser's developer console for JavaScript errors
  • Verify you're running a supported PHP version (8.1+) and Laravel version (10+)
  • Clear your application cache: php artisan cache:clear

If issues persist, check the troubleshooting documentation for more detailed debugging steps.