laravel/jetstream
Laravel Jetstream is a starter kit for Laravel 11.x and earlier, providing a ready-made application foundation with common auth and account features. For newer starter kits, see https://laravel.com/starter-kits.
Installation:
composer require laravel/jetstream
php artisan jetstream:install livewire # or inertia for SPA
npm install && npm run dev
php artisan migrate
livewire for server-rendered or inertia for SPA (Vue/React) workflows.First Use Case:
/register to test the registration flow, then /dashboard to interact with the pre-built profile/team management UI.npm run dev and visit /login to test the SPA-based auth flow.Key Directories:
app/Http/Livewire (e.g., ManageAccountSettings, DeleteUser).resources/js/Pages (e.g., Dashboard.vue, Profile/UpdateProfileInformation.vue).resources/views/layouts (shared layouts like app.blade.php).database/migrations/ (user/team tables).First Customization:
app/Http/Livewire/ManageAccountSettings.php to your app and modifying it.resources/js/Pages/Profile/UpdateProfileInformation.vue and customizing the template/data.Login/Registration: Jetstream handles sessions, password resets, and email verification out-of-the-box. Extend by publishing views:
php artisan vendor:publish --tag=jetstream-views
Modify resources/views/auth/ files (e.g., login.blade.php).
Two-Factor Auth (2FA):
Enable via php artisan jetstream:install (select "2FA"). Customize the recovery codes view at resources/views/livewire/two-factor-recovery-codes.blade.php.
Middleware:
Jetstream registers auth and verified middleware. Add custom middleware to app/Http/Kernel.php:
'web' => [
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\Authenticate::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Laravel\Jetstream\Http\Middleware\VerifyCsrfToken::class, // Jetstream-specific CSRF
],
ManageAccountSettings Livewire component or UpdateProfileInformation Inertia page. Extend by overriding the form logic:
// app/Http/Livewire/ManageAccountSettings.php
public function updateProfileInformation()
{
$this->validate([
'photo' => ['nullable', 'image'],
'name' => ['required', 'string', 'max:255'],
]);
// Custom logic here
}
Team model or modifying the InviteTeamMembers Livewire component.Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
routes/api.php or customizing the Sanctum auth guard in config/auth.php.tailwind.config.js or extend the base styles in resources/css/app.css.DarkMode Livewire component (or Inertia equivalent). Customize the toggle button in resources/views/components/dark-mode-toggle.blade.php.resources/views/layouts. Extend by copying and modifying (e.g., app.blade.php).php artisan test
$user = User::factory()->create();
$response = $this->actingAs($user)->get('/dashboard');
$response->assertStatus(200);
$this->livewire(ManageAccountSettings::class)->assertSee('Profile Settings');
Livewire + Inertia Hybrid: Use Livewire for complex server-side interactions (e.g., file uploads) and Inertia for SPA-like routing. Example:
<!-- resources/js/Pages/Dashboard.vue -->
<template>
<AppLayout>
<LivewireManageAccountSettings />
</AppLayout>
</template>
Custom Validation: Extend Jetstream’s form requests. Publish and modify:
php artisan vendor:publish --tag=jetstream-form-requests
Then override app/Http/Requests/UpdateProfileInformationRequest.php.
Event Listeners:
Listen to Jetstream events (e.g., Registered, ProfileUpdated) in EventServiceProvider:
protected $listen = [
'Laravel\Jetstream\Events\Registered' => [
\App\Listeners\LogNewUser::class,
],
];
Seeding: Use Jetstream’s factories to seed users/teams:
// database/seeders/DatabaseSeeder.php
$user = User::factory()->create();
$team = Team::factory()->create(['user_id' => $user->id]);
Localization: Publish language files:
php artisan vendor:publish --tag=jetstream-lang
Then extend resources/lang/en/ or add new locales.
Middleware Registration:
VerifyCsrfToken middleware may conflict with Laravel’s default if not ordered correctly in Kernel.php.VerifyCsrfToken:
'web' => [
// ... other middleware
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Laravel\Jetstream\Http\Middleware\VerifyCsrfToken::class, // Must come after SubstituteBindings
],
Inertia vs. Livewire Routes:
inertia. in routes/web.php:
Route::inertia('/dashboard', 'Dashboard')->middleware(['auth', 'verified']);
Team Ownership:
user_id foreign key. Customizing this requires updating migrations and models.Team model’s user() relationship or publish and modify migrations:
php artisan vendor:publish --tag=jetstream-migrations
Two-Factor Auth Quirks:
two_factor_recovery_codes table isn’t created.php artisan migrate
Livewire Component Registration:
HandleInertiaRequests middleware is misconfigured.ShareRequestsWithView middleware is registered in Kernel.php:
\Laravel\Jetstream\Http\Middleware\ShareRequestsWithView::class,
Vite Asset Conflicts:
vite.config.js:
import laravel from 'laravel-vite-plugin';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
// Your custom plugins
],
});
Database Migrations:
php artisan migrate after Jetstream installation may fail if the users table already exists.--force or manually resolve conflicts:
php artisan migrate --force
How can I help you explore Laravel packages today?