Skip to content

Commit c3cafda

Browse files
committed
Update README, add "Flash Messages"
1 parent b8b1c0c commit c3cafda

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Feel free to contribute to the project by creating issues or pull requests.
2323
* [Backend](#backend)
2424
- [Features](#features)
2525
* [Shared data](#shared-data)
26+
* [Flash Messages](#flash-messages)
2627
* [Server-side rendering](#server-side-rendering)
2728
* [Vite helper](#vite-helper)
2829
- [Examples](#examples-1)
@@ -181,6 +182,26 @@ app.AddInertiaSharedData(httpContext => new InertiaProps
181182
});
182183
```
183184

185+
### Flash Messages
186+
187+
You can add flash messages to your responses using the `Inertia.Back(url).WithFlash(...)` method.
188+
189+
```csharp
190+
[HttpDelete("{id:int}")]
191+
public async Task<IActionResult> Destroy(int id)
192+
{
193+
/// find user
194+
195+
if (!user.IsAdmin)
196+
return Inertia.Back().WithFlash("error", "Admins cannot be deleted.");
197+
198+
// delete user
199+
200+
return Inertia.Back().WithFlash("success", "User deleted.");
201+
}
202+
```
203+
204+
184205
### Server-side rendering
185206

186207
If you want to enable SSR in your Inertia app, remember to add `Inertia.Head()` to your layout:

0 commit comments

Comments
 (0)