Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel One Time Passwords Laravel Package

spatie/laravel-one-time-passwords

Generate and verify secure one-time passwords (6‑digit by default) in Laravel. Sends OTPs via mail notifications (extendable to SMS/other channels) and includes a Livewire login component. Optional Flux support provides an enhanced OTP input UI.

View on GitHub
Deep Wiki
Context7

title: Using the Livewire component weight: 5

The package provides a Livewire component that can create and consume one-time passwords. Here's how you can use it in your view.

<livewire:one-time-password>

It will render a form asking for the user's email address and a button to send the one-time password. After the user submits the form, it will send a one-time password to the provided email address.

image

The component will then display a form asking for the one-time password and a button to verify it. After the user submits the form, it will verify the one-time password and log the user in if the verification is successful.

image

Only consuming a one-time password

If you want to use the component only for consuming a one-time password, you can pass the email prop to the component.

<livewire:one-time-password email="johndoe@example.com">

This will skip the email address input and directly show the form for entering the one-time password.

Redirecting after successful authentication

By default, authenticated users will be redirected to the url specified in the redirect_successful_authentication_to property of the one-time-passwords config file.

To customize the redirect URL, you can also pass an url to the redirect-to prop.

<livewire:one-time-password :redirect-to="route('home')">

Using the Flux OTP input component

When Flux is installed, the Livewire component will automatically use the Flux OTP input component, which is much nicer than the default text input.

You can install Flux by following the instructions on their website: https://fluxui.dev

Once Flux is installed, the package will automatically detect it and use the Flux OTP input component instead of the default text input.

image

Customizing the styling

You can customize the styling of the component by publishing the package's assets. To do this, run the following command:

php artisan vendor:publish --tag=one-time-passwords-views

This will publish the package's views to the resources/views/vendor/one-time-passwords directory. You can then customize the views as needed.

Customizing the component

To have full control over the component, you can create your own Livewire component, and let it extend Spatie\OneTimePasswords\Livewire\OneTimePasswordComponent.

This way, you can override any methods or properties you want.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai