sveltekit-flash-message
Purpose: The library facilitates passing temporary data (flash messages) between requests in SvelteKit, commonly used to display success/error messages after form submissions or redirects. It encourages web apps to follow the "Redirect After Post" pattern.
Target Audience: SvelteKit developers who need to manage transient messages across page navigations, especially in form actions and endpoints.
Key Features:
- Server-side flash message handling with
redirectandsetFlashfunctions. - Client-side integration via
getFlashstore for displaying messages. - Supports toast notifications via event-style effects.
- Configurable options like auto-clear timers (
clearAfterMs) and navigation behavior (clearOnNavigate). - Works alongside Superforms for enhanced form handling.
- Server-side flash message handling with
SvelteKit Support: Primarily designed for SvelteKit, with seamless integration into load functions, form actions, and endpoints. Requires minimal setup in
+layout.server.tsand+layout.svelte.Security Note: Flash messages are transferred via cookies and should be treated as untrusted user input (avoid
{@html}usage).Migration: Simplified APIs in v2.x (e.g.,
loadFlashreplacesloadFlashMessage), with automatic navigation clearing.
For issues or feedback, visit the GitHub repository .