Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Laravel

Livewire Redirect After Action

Handle redirects properly in Livewire after form submissions.

16 January 20261 min readLaravelاقرأ بالعربية

On this page

  1. Basic Redirect
  2. With Flash Message
  3. Navigate Without Refresh
  4. Redirect to Component

Redirect after actions:

Basic Redirect

php
public function save()
{
    Post::create($this->data);
    return redirect()->route('posts.index');
}

With Flash Message

php
public function save()
{
    Post::create($this->data);
    session()->flash('success', 'Post created!');
    return redirect()->route('posts.index');
}

Navigate Without Refresh

php
public function save()
{
    Post::create($this->data);
    return $this->redirect('/posts', navigate: true);
}

Redirect to Component

php
return $this->redirectRoute('posts.show', ['post' => $post]);
All articles

Keep reading

  • Laravel Action Classes Pattern16 January 20261 min read
  • Laravel Action Classes: Single Responsibility16 January 20261 min read
  • Laravel API Rate Limiting16 January 20261 min read