How to make Filament (V2) Login page automatically fill in a local environment

Search for a command to run...

No comments yet. Be the first to comment.
Fun fact, while deep diving how Claude Code works, I realised some files were stored with a .jsonl format! What’s this, a typo?? 😀 Of course not…. It's a text format where each LINE is a valid JSON object. So why this and not just a JSON array?! Reg...

This apply the dependencies transformations needed, and add the PostCSS config file needed. npm remove @tailwindcss/vite npm remove tailwindcss npm install tailwindcss@3 @tailwindcss/forms npm install postcss autoprefixer cat > postcss.config.js ...

Warning: I just deprecated it. Claude Code is fantastic, it does the same job I wanted to achieve with this. It’s a CLI instead of an UI, but it does 10x or 100x more than the current application situation. Get it here: https://docs.anthropic.com/en/...

I know, Livewire and Tailwind are the base for Filament, and this tutorial is not any hidden gem, but my gut feeling tells me I should write it. It shows few steps of the docs, but many don't get there, and don't even know this is possible. Filament ...

You're reading this, so you want the Login page ready to go in local environments, without having to type in a default user (configured in your seeder). Let's go. Let's create a Filament Page. Press <enter> for an empty answer, when asked if the page...

Basically, you need to control the Login page, so let's create one.
php artisan make:filament-page Login
Let's edit it so that we extend the base one \Filament\Http\Livewire\Auth\Login, and override the base mount method, while conditionally pre-fill the form with convenient seed data.
<?php
namespace App\Filament\Pages;
use Filament\Facades\Filament;
class Login extends \Filament\Http\Livewire\Auth\Login
{
public function mount(): void
{
parent::mount();
if (app()->environment('local')) {
$this->form->fill([
'email' => 'test@example.com',
'password' => 'password',
'remember' => true,
]);
}
}
}
Don't forget to change the page to use for Login, using our own instead of the default. We do this in config/filament.php file:
// config/filament.php
// ...
'auth' => [
'guard' => env('FILAMENT_AUTH_GUARD', 'web'),
'pages' => [
'login' => \App\Filament\Pages\Login::class,
],
],
//...
If you don't have the config, just publish it by running:
php artisan vendor:publish --tag=filament-config
That's it! Let me know how it went for you. As for me, every little increment of UX/DX adds up over time, making it a gazillion times better!
Happy coding! 🚀