Courses

React.js + Inertia in Laravel 11: From Scratch

Flash Success Messages in Inertia

Summary of this lesson:
- Add success messages after form submission
- Use middleware to share flash messages
- Access shared data in React components
- Display temporary notifications
- Implement global message sharing

Let's show some success messages when submitting the form.

It is very common to show some success message when redirecting back.

app/Http/Controllers/PostController.php:

class PostController extends Controller
{
// ...
 
public function store(StorePostRequest $request): RedirectResponse
{
Post::create($request->validated());
 
return redirect()->route('posts.index')
->with('message', 'Post created successfully.');
}
}

But how do we catch this message in Inertia? We must pass that variable as...

The full lesson is only for Premium Members.
Want to access all 18 lessons of this course? (57 min read)

You also get:

  • 69 courses (majority in latest Laravel 11)
  • Premium tutorials
  • Access to repositories
  • Private Discord