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
Inertia Laravel

Inertia Laravel Laravel Package

inertiajs/inertia-laravel

Official Laravel adapter for Inertia.js. Build modern single-page apps using classic server-side routing and controllers, without building an API. Provides Inertia responses, shared props, middleware helpers, and integration with Laravel features.

View on GitHub
Deep Wiki
Context7

The Laravel adapter for Inertia.js.

Frequently asked questions about Inertia Laravel
How do I migrate from Blade to Inertia.js in Laravel without breaking existing routes?
Use the `Inertia::render()` method in your controllers to replace Blade views incrementally. The package supports hybrid rendering, so you can keep Blade for legacy pages while adopting Inertia for new ones. Start by converting one route at a time and test thoroughly. Middleware like `Share` helps pass shared data seamlessly between Blade and Inertia pages.
Does inertiajs/inertia-laravel support Laravel 11 and PHP 8.5?
Yes, the package officially supports Laravel 10+, including Laravel 11, and is tested with PHP 8.1–8.5. Check the [release notes](https://github.com/inertiajs/inertia-laravel/releases) for version-specific updates. If you’re using Laravel 11, ensure your `composer.json` requires the latest stable version of the package.
How can I optimize performance with deferred props in Inertia for Laravel?
Use the `defer()` or `once()` methods in your controllers to load non-critical data after the initial page render. This reduces payload size and improves load times. For example, defer heavy computations or lazy-load content like comments or analytics. Monitor hydration mismatches in your frontend framework to ensure data consistency.
Will Inertia.js work with Laravel Sanctum for authentication?
Yes, Inertia.js integrates seamlessly with Laravel Sanctum. Use Sanctum’s middleware to protect routes, and Inertia will handle the auth state automatically via shared props. For example, pass `auth.user` to your frontend to manage login states. The package also supports Laravel’s built-in session auth for hybrid setups.
Can I use Inertia with Vue 3 or Svelte alongside React in the same Laravel app?
Absolutely. Inertia.js is framework-agnostic, so you can mix React, Vue 3, or Svelte components in the same app. Each page specifies its preferred framework via the `Inertia.render()` method. For example, use `Inertia.render('Dashboard', { framework: 'vue' })` for Vue-specific pages. This flexibility lets you adopt the best tool for each feature.
How do I test Inertia responses in PHPUnit for Laravel?
The package includes PHPUnit macros like `assertInertia()` and `assertInertiaFlash()` to simplify testing. For example, test a controller by asserting the rendered Inertia response: `assertInertia(fn() => route('dashboard'));`. Combine these with Laravel’s HTTP tests to verify redirects, flash data, and middleware behavior. End-to-end tests (e.g., Playwright) can validate frontend interactions.
What’s the best way to handle flash messages (e.g., success alerts) in Inertia for Laravel?
Use Laravel’s built-in `session()->flash()` method to store messages, and Inertia will automatically pass them to your frontend via shared props. For example, after a form submission, flash a success message: `session()->flash('success', 'Profile updated!');`. In your frontend, access these messages using Inertia’s `usePage` hook or similar framework-specific methods.
Do I need Node.js for Inertia.js in Laravel, and how does SSR work?
Node.js is required for SSR (Server-Side Rendering) because Inertia.js uses Vite or Laravel Mix to compile frontend assets. SSR renders pages on the server for better SEO and initial load performance. If you’re not using SSR, Node.js is only needed for development builds. For production, ensure your server supports Node.js if using SSR.
How can I debug hydration mismatches between Laravel and my React/Vue frontend?
Hydration mismatches occur when server-rendered HTML doesn’t match the client-side DOM. Use browser dev tools to compare the server and client-side HTML. In React/Vue, enable strict mode or use Inertia’s `debug: true` config to log mismatches. Check for dynamic data (e.g., timestamps, user-specific content) that might differ between server and client.
Are there alternatives to inertiajs/inertia-laravel for Laravel SPAs, and why should I choose this one?
Alternatives include Laravel Livewire (for Blade-based SPAs) or building a custom API with Laravel + frontend frameworks. Inertia.js stands out because it lets you use Laravel’s controllers, routes, and middleware without rewriting logic. It’s officially maintained, supports SSR/CSR, and integrates natively with React/Vue/Svelte. For teams already using Laravel, it’s the fastest path to a modern SPA.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony