Can we use session flash in component and printing in layouts/app.blade.php

What seems to be the problem: the session message is not printing in app.blade.php

Steps to Reproduce:

Are you using the latest version of Livewire: 2.0 and laravel 8

Do you have any screenshots or code examples:
layouts/demo.blade.php
@if (session()->has(‘message.text’))


×
{{ session(‘message.text’) }}

@endif
/////////////////////
livewire:
category.php livewire component
session()->flash(‘message’, [
‘text’=>‘delete successfully’,
‘type’=>‘error’,
]);

If the part of the code that checks session is not in the rendered view then that code will not be evaluated.

You can consider my approach to using an event fired by the Livewire component, https://talltips.novate.co.uk/livewire/sweetalert2-with-livewire in this case firing a Sweet Alert popup, but could be adapted.

is there solution with session that is the first priority that why if no then will go with sweetAlert

You can use session but what would be the point?

Move your banner or popup into its own component and setup a listener so that it re-renders if it hears an event from your component. The message can be passed by session, but it would not be a flash meaning that you would need to delete it from session after rendering it.

Just to be clear, your idea of using session flash and then checking for it is based on the premise of a full-page refresh. Sweet Alert is not being proposed as a solution, sending an event is what I am proposing.