Menu
Libraries |
Category

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 redirect and setFlash functions.
    • Client-side integration via getFlash store 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.
  • SvelteKit Support: Primarily designed for SvelteKit, with seamless integration into load functions, form actions, and endpoints. Requires minimal setup in +layout.server.ts and +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., loadFlash replaces loadFlashMessage), with automatic navigation clearing.

For issues or feedback, visit the GitHub repository .

cookiesflash-messagessessionsveltesveltekit

Comments