Redirecting

You may want to redirect from inside a Livewire component to another route in your app. Livewire offers two methods to achieve this; a builtin $this->redirect() method and support for Laravel redirects :

use Livewire\Component;

class ContactForm extends Component
{
    public $email;

    public function addContact()
    {
        Contact::create(['email' => $this->email]);

        $this->redirect('/contact-form-success');

        //OR

        return redirect()->to('/contact-form-success');

    }

    public function render()
    {
        return view('livewire.contact-form');
    }
}
<div>
    Email: <input wire:model="email">

    <button wire:click="addContact">Submit</button>
</div>

Now, after the user clicks "Submit" and their contact is added to the database, they will be redirected to the success page (/contact-form-success).