All articles

The Perfect Passwordless Authentication Stack for Laravel

4 min readLaravel

I've been implementing authentication systems for years, and I'm done with passwords. They're a terrible user experience. People reuse them, forget them, and create weak ones that get compromised. But what's the alternative?

Auth provider Clerk.dev published data from 2.5 million sign-ins that finally answers this question with hard numbers. The results are clear: users overwhelmingly prefer social login when given the choice.

The Data That Changed My Approach

Here's what 2.5 million authentication attempts revealed:

StrategySeconds to AuthUser Preference
Sign In with Google3.8665%
Password7.2227%
Email OTP42.845.3%
Magic Link56.851.6%

The correlation between speed and preference is undeniable. Social login wins by a landslide. But here's the thing: you can't rely on social login alone. Not everyone has a Google account. Not everyone stays signed in across devices.

That's why I've developed what I believe is the perfect passwordless authentication stack for Laravel applications.

My Perfect Passwordless Stack

After building multiple authentication systems and analyzing this data, here's the stack I now use for every new Laravel project:

MethodPackageUse CaseImplementation Time
Social LoginLaravel SocialitePrimary authentication (65% of users)30 minutes
One-Time PasswordsOTPzFallback for non-social users15 minutes
Magic LinksPlinkHigh-security scenarios15 minutes
PasskeysWebAuthnPower users wanting instant access1 hour

This combination handles every scenario I've encountered in production.

Why This Stack Works

Social login handles the majority. With 65% of users preferring it, implementing Google Sign-In with Laravel Socialite is a no-brainer. It's fast, familiar, and provides pre-verified email addresses. Setup takes about 30 minutes including OAuth configuration.

OTPs provide the universal fallback. When someone doesn't have a Google account or isn't signed in on their current device, they need an alternative. OTPs beat magic links by 14 seconds because users can view codes on their phone while authenticating on their laptop. No context switching to email on the same device.

Magic links serve specific needs. While slower, they're more secure against phishing. I use these for admin panels or sensitive operations where the extra security justifies the friction.

Passkeys deliver the future. For power users who want instant authentication without sharing data with Google, passkeys provide the best of both worlds. They're fast like social login but completely private.

Implementation in Laravel

Here's how I set up this stack in a new Laravel application:

Step 1: Social Login with Socialite

First, I install and configure Socialite for Google authentication:

bash
composer require laravel/socialite

The controller is straightforward:

php
public function redirectToGoogle()
{
    return Socialite::driver('google')->redirect();
}

public function handleGoogleCallback()
{
    $googleUser = Socialite::driver('google')->user();
    
    $user = User::updateOrCreate(
        ['email' => $googleUser->getEmail()],
        [
            'name' => $googleUser->getName(),
            'email_verified_at' => now(),
        ]
    );
    
    Auth::login($user);
    return redirect('/dashboard');
}

Step 2: OTP Fallback with OTPz

For users without social accounts, I implement OTPz:

bash
composer require benbjurstrom/otpz

The implementation is clean:

php
use BenBjurstrom\Otpz\Models\Otp;

// Send OTP
$otp = Otp::make($request->email);
Mail::to($request->email)->send(new OtpMail($otp));

// Verify OTP
$user = Otp::verify($request->email, $request->code);
if ($user) {
    Auth::login($user);
    return redirect('/dashboard');
}

For high-security scenarios, I add Plink:

bash
composer require benbjurstrom/plink

Plink provides session-locked magic links that prevent email scanner interference:

php
use BenBjurstrom\Plink\Models\Link;

// Create and send link
$link = Link::make($user);
Mail::to($user)->send(new MagicLinkMail($link));

// Verification happens automatically via middleware

Step 4: Passkeys for Power Users

Passkeys require more setup but provide the best user experience for repeat visitors. I use the Laravel WebAuthn package for implementation.

The User Journey

Here's how this stack works in practice:

  1. New user arrives and sees "Sign in with Google" prominently displayed
  2. If they use Google, they're authenticated in under 4 seconds with a verified email
  3. If they don't have Google, they enter their email and receive an OTP
  4. Power users can enable passkeys after initial authentication for instant future access
  5. High-security operations trigger magic link verification regardless of login method

This approach respects user preferences while maintaining security and providing fallbacks for edge cases.

Real-World Considerations

After deploying this stack in production, I've learned a few things:

Rate limiting is critical. Both OTPz and Plink include configurable rate limiting. I typically allow 3 attempts per hour for OTPs and 5 magic link requests per day.

Email delivery matters. The difference between OTPs and magic links becomes pronounced with slow email providers. I use Amazon SES for consistent sub-second delivery.

Monitoring is essential. Both packages emit events at key moments. I track authentication attempts, failures, and unusual patterns using Laravel Pulse.

Skip the Password Reset Emails

The beauty of this stack? No password reset emails. No weak passwords. No credential stuffing attacks. Just smooth, secure authentication that users actually prefer.

Every Laravel application I build now starts with this stack. Setup takes about 2 hours total, and the improved user experience is immediate. Users sign up faster, abandon carts less frequently, and never complain about forgotten passwords.

If you're starting a new Laravel project or modernizing an existing one, implement this stack. Your users already prefer it, and the data proves it works.