laravel/jetstream
Official Laravel 11 starter kit for building apps with authentication, teams, profiles, API tokens, and more. Choose Livewire or Inertia stacks and get a robust, production-ready foundation quickly.
Installation
Run composer require laravel/jetstream in a fresh Laravel 11.x project.
Use the installer: php artisan jetstream:install livewire (or inertia for Inertia.js).
This sets up:
First Use Case
/register to test the registration flow./login to authenticate./profile to update user details, upload a profile photo, or enable 2FA.Where to Look First
app/Http/Controllers/Auth/ (Auth logic)app/Models/ (User, Team models)resources/views/ (Blade templates for Livewire/Inertia)resources/js/Pages/ (Inertia.js pages, if using Inertia)config/jetstream.php (customize features like teams, 2FA, or API tokens).database/migrations/ (user, team, and session tables).app/Http/Livewire/ or resources/js/Pages/Auth/.
Example: Extend CreateUserForm to add custom validation:
// app/Http/Livewire/Auth/CreateUserForm.php
public function rules()
{
return array_merge(parent::rules(), [
'custom_field' => 'required|string',
]);
}
app/Http/Controllers/Auth/RegisteredUserController for custom registration logic.Team::inviteUser() to send invites. Customize the invite logic in app/Actions/Jetstream/InviteTeamMember.php.team->assignRoleToMember($user, 'admin'). Extend app/Models/Team.php to add custom roles.canJoinTeam or mustBelongToTeam middleware (defined in app/Http/Middleware/).app/Models/User::profilePhotoUrl() to customize photo paths. Override the accessor:
public function profilePhotoUrl()
{
return 'custom/path/' . $this->profile_photo_path;
}
app/Models/User and update:
app/Http/Livewire/Profile/UpdateProfileInformationForm.phpresources/js/Pages/Profile/UpdateProfileInformation.vue (Inertia).config/jetstream.php ('features' => ['api' => true]). Use user->createToken() to generate tokens.app/Http/Controllers/Auth/Sanctum/AuthenticatedSessionController for custom API logic.resources/views/vendor/jetstream/.app/Mail/ to customize verification/notification emails.User::factory() or Team::factory() in tests.actingAs() for authentication and followRedirects() for testing flows:
$user = User::factory()->create();
$response = $this->actingAs($user)->get('/profile');
app/Providers/AppServiceProvider:
public function boot()
{
Livewire::component('custom-component', \App\Livewire\CustomComponent::class);
}
resources/js/Pages/. Use useForm for reactive forms:
<script setup>
import { useForm } from '@inertiajs/inertia-vue3';
const form = useForm({ ... });
</script>
app/Http/Kernel.php under the web group:
'web' => [
\App\Http\Middleware\CustomMiddleware::class,
// ...
],
app/Policies/ to restrict access (e.g., UserPolicy, TeamPolicy).Migration Conflicts
php artisan migrate after Jetstream installation may fail if custom migrations exist for users or teams tables.php artisan jetstream:install --migrate to handle migrations safely or manually merge migration files.Livewire/Inertia Incompatibility
Inertia.render() for Livewire components or vice versa sparingly. Prefer one stack per project.Team Ownership Logic
app/Actions/Jetstream/DeleteTeam.php:
public function handle()
{
if ($this->team->members()->count() <= 1) {
throw ValidationException::withMessages(['team' => ['Cannot delete the last team owner.']]);
}
// ...
}
Session Handling
config/session.php to use database or file drivers and ensure SESSION_DRIVER is set in .env.Two-Factor Authentication (2FA)
php artisan jetstream:recover-2fa to regenerate recovery codes for existing users.API Token Scopes
app/Models/User and override tokens():
public function tokens()
{
return $this->hasMany(\Laravel\Sanctum\PersonalAccessToken::class)->addSelect(['id', 'tokenable_id', 'tokenable_type', 'name', 'abilities', 'created_at', 'updated_at']);
}
Livewire Debugging
php artisan livewire:discover to refresh components.storage/logs/livewire.log for component errors.Inertia Debugging
resources/js/app.js:
import { createInertiaApp } from '@inertiajs/inertia-vue3';
createInertiaApp({
resolve: name => require(`./Pages/${name}.vue`),
setup({ el, App, props, plugin }) {
window.Inertia.debug = true; // Enable debug mode
createApp({ render: () => h(App, props) })
.use(plugin)
.mount(el);
},
});
Team Invitation Issues
team_invitations table exists and invitable trait is added to User model.config/jetstream.php for team_invitations table name.Profile Photo Uploads
public/storage/app/public is symlinked to storage/app/public:
php artisan storage:link
filesystem.php config for public disk:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Custom Features
app/Http/Controllers/Auth/SocialiteController and update config/auth.php.app/Models/Team role logic with a middleware-based system (e.g., app/Http/Middleware/CheckTeamRole.php).Theming
resources/css/app.cssHow can I help you explore Laravel packages today?