Filament: No-Password Login Link for Local Testing

Free Snippet

If you need to test project(s) locally and don't want to enter login/password every time, you can use a plugin by Spatie and hook it into Filament.

filamentexamples-thumbnail (5)

How it works

First, you need to install the package spatie/laravel-login-link:

composer require spatie/laravel-login-link

Read its documentation for additional configuration options.

Then, add a renderHook to the Filament Panel provider:

app/Providers/Filament/AdminPanelProvider.php:

use Filament\View\PanelsRenderHook;
use Illuminate\Support\Facades\Blade;
 
// ...
 
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ... other configuration options
// ->...()
->renderHook(
PanelsRenderHook::AUTH_LOGIN_FORM_BEFORE,
fn (): string => Blade::render('@env(\'local\')<x-login-link />@endenv'),
);
}
}

It will show the login link above the Email field in the login form.

By default, it will auto-login you with the first user in the users DB table, without typing its email/password.

Important: it will (and is intended to) work only on local environment, judging from your .env file value of APP_ENV=local. So, don't forget to change this value to "production" when deploying to the live server.

For more configuration options, follow the docs of the spatie/laravel-login-link package.

A few of our Premium Examples: