From the course: Building a Website with Laravel, React.js, and Inertia

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Challenge: Show a flash message

Challenge: Show a flash message

(bright music) - [Instructor] We have now created a fully functional block with Laravel, Inertia, and React. Even though we covered the main functionality, there is still so much more we could do. For this challenge, I'm going to ask you to show a flash message when a post gets created, updated, and deleted. To do that, you can use Inertia's shared data. Shared data allows access to data on numerous pages. For instance, think about a username. This may be displayed on the homepage, in the site header, and other different places. Passing this in manual in each response wouldn't be a great developer experience. Another great use for shared data are flash messages as we are doing here. To handle shared data, you will first need to enable it in the HandleInertiaRequest middleware. And then you'll be able to access the data using the usePage().props object. You can read more about what to do in the Inertia documentation here.

Contents