PHPackages                             spatie/laravel-one-time-passwords - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. spatie/laravel-one-time-passwords

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

spatie/laravel-one-time-passwords
=================================

Use one-time passwords (OTP) to authenticate in your Laravel app

1.0.11(2mo ago)170223.1k↑15.4%25[1 PRs](https://github.com/spatie/laravel-one-time-passwords/pulls)2MITPHPPHP ^8.4CI passing

Since May 14Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/spatie/laravel-one-time-passwords)[ Packagist](https://packagist.org/packages/spatie/laravel-one-time-passwords)[ Docs](https://github.com/spatie/laravel-one-time-passwords)[ GitHub Sponsors](https://github.com/Spatie)[ RSS](/packages/spatie-laravel-one-time-passwords/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (20)Versions (20)Used By (2)

 [   ![Logo for laravel-permission](https://camo.githubusercontent.com/583962e32d9bc1c18cd13eba9e245235c374bc899840029b8e5460f4a68d8da7/68747470733a2f2f7370617469652e62652f7061636b616765732f6865616465722f6c61726176656c2d6f6e652d74696d652d70617373776f7264732f68746d6c2f6c696768742e776562703f31373437343032313530)  ](https://spatie.be/open-source?utm_source=github&utm_medium=banner&utm_campaign=laravel-one-time-passwords)One-time passwords (OTP) for Laravel apps
=========================================

[](#one-time-passwords-otp-for-laravel-apps)

[![Latest Version on Packagist](https://camo.githubusercontent.com/14d02c862560129c58c3495c101b9d3fe5ac9ef7647956ac5bea8c25a90b8849/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d6f6e652d74696d652d70617373776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-one-time-passwords)[![GitHub Tests Action Status](https://camo.githubusercontent.com/a2622c2ec7ce871a283dada1582322478658dae9b6eedcf76a107af05809b977/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d6f6e652d74696d652d70617373776f7264732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-one-time-passwords/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/aad1ca48f24aae5ce3eaec42142afda9f872e0eea4e058ce3d46f70c48fe27df/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d6f6e652d74696d652d70617373776f7264732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-one-time-passwords/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/629a07e862b7454edcc3f07e476d85fb43dad5230460e60fd84721ccf5c5f3b5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d6f6e652d74696d652d70617373776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-one-time-passwords)

Using this package, you can securely create and consume one-time passwords. By default, a one-time password is a number of six digits long that will be sent via a mail notification. This notification can be extended so it can be sent via other channels, like SMS.

The package ships with a Livewire component to allow users to log in using a one-time password.

[![image](/docs/images/form-email.png)](/docs/images/form-email.png)

[![image](/docs/images/form-code.png)](/docs/images/form-code.png)

### Enhanced UI with Flux

[](#enhanced-ui-with-flux)

For an improved OTP input experience, you can optionally install [Flux](https://fluxui.dev). When Flux is detected, the package will automatically use the [Flux OTP input component](https://fluxui.dev/components/otp-input) instead of a standard text input.

To install Flux, follow the instructions on their website:

### Build your own UI

[](#build-your-own-ui)

Alternatively, you can build the one-time password login flow you want with the easy-to-use methods the package provides.

Here's how you would send a one-time password to a user

```
// send a mail containing a one-time password

$user->sendOneTimePassword();
```

This is what the notification mail looks like:

[![image](/docs/images/otp-notification.png)](/docs/images/otp-notification.png)

Here's how you would try to log in a user using a one-time password.

```
use Spatie\OneTimePasswords\Enums\ConsumeOneTimePasswordResult;

$result = $user->attemptLoginUsingOneTimePassword($oneTimePassword);

if ($result->isOk()) {
     // it is best practice to regenerate the session id after a login
     $request->session()->regenerate();

     return redirect()->intended('dashboard');
}

return back()->withErrors([
    'one_time_password' => $result->validationMessage(),
])->onlyInput('one_time_password');
```

The package tries to make one-time passwords as secure as can be by:

- letting them expire in a short timeframe (2 minutes by default)
- only allowing to consume a one-time password on the same IP and user agent as it was generated

All behavior is implemented in action classes that can be modified to your liking.

Documentation
-------------

[](#documentation)

All documentation is available [on our documentation site](https://spatie.be/docs/laravel-one-time-passwords).

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/0a36450c5ebed651c743183136346546c7b1521167cd39f69ac075b7d04636c7/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d6f6e652d74696d652d70617373776f7264732e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-one-time-passwords)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance87

Actively maintained with recent releases

Popularity54

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 80.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Recently: every ~23 days

Total

17

Last Release

81d ago

Major Versions

0.0.4 → 1.0.02025-05-20

PHP version history (3 changes)0.0.1PHP ^8.4

1.0.4PHP ^8.2

1.0.6PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (153 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![sdebacker](https://avatars.githubusercontent.com/u/134503?v=4)](https://github.com/sdebacker "sdebacker (4 commits)")[![ShadyMNabil](https://avatars.githubusercontent.com/u/134545007?v=4)](https://github.com/ShadyMNabil "ShadyMNabil (4 commits)")[![x-JOC](https://avatars.githubusercontent.com/u/185681086?v=4)](https://github.com/x-JOC "x-JOC (3 commits)")[![Ayoub-Mabrouk](https://avatars.githubusercontent.com/u/77799760?v=4)](https://github.com/Ayoub-Mabrouk "Ayoub-Mabrouk (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")[![jimirobaer](https://avatars.githubusercontent.com/u/8984769?v=4)](https://github.com/jimirobaer "jimirobaer (2 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![lorenzolosa](https://avatars.githubusercontent.com/u/11164571?v=4)](https://github.com/lorenzolosa "lorenzolosa (2 commits)")[![kidiatoliny](https://avatars.githubusercontent.com/u/48266788?v=4)](https://github.com/kidiatoliny "kidiatoliny (1 commits)")[![BurtDS](https://avatars.githubusercontent.com/u/2655353?v=4)](https://github.com/BurtDS "BurtDS (1 commits)")[![Matse2005](https://avatars.githubusercontent.com/u/49431416?v=4)](https://github.com/Matse2005 "Matse2005 (1 commits)")[![mTresk](https://avatars.githubusercontent.com/u/33250247?v=4)](https://github.com/mTresk "mTresk (1 commits)")[![ibra-br](https://avatars.githubusercontent.com/u/67363656?v=4)](https://github.com/ibra-br "ibra-br (1 commits)")[![gpluess](https://avatars.githubusercontent.com/u/598360?v=4)](https://github.com/gpluess "gpluess (1 commits)")[![spoyntersmith](https://avatars.githubusercontent.com/u/22387308?v=4)](https://github.com/spoyntersmith "spoyntersmith (1 commits)")[![agungsugiarto](https://avatars.githubusercontent.com/u/10989147?v=4)](https://github.com/agungsugiarto "agungsugiarto (1 commits)")

---

Tags

authenticationlaravelotppasswordsspatielaravellaravel-one-time-passwords

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spatie-laravel-one-time-passwords/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-one-time-passwords/health.svg)](https://phpackages.com/packages/spatie-laravel-one-time-passwords)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.7M41](/packages/jeffgreco13-filament-breezy)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
