@webhandle/tracker-flash-message
v1.0.1
Published
Flash messages are messages stored in a cookie that are to be displayed to the user upon next request. It's a way keep some sort of state, if only during one redirect, and still have the server be stateless and without the need for a db to hold user sessi
Readme
@webhandle/tracker-flash-messages
Flash messages are messages stored in a cookie that are to be displayed to the user upon next request. It's a way keep some sort of state, if only during one redirect, and still have the server be stateless and without the need for a db to hold user sessions.
Configuration
import setupFlashMessages from "@webhandle/tracker-flash-message/initialize-webhandle-component.mjs"
await setupFlashMessages(webhandle)Usage
To add a flash message:
await res.addFlashMessage('my message')To read the flash messages:
await req.getFlashMessages()You must await both of these calls because they both modify cookies. getFlashMessages() clears the
messages. However, it can be called multiple times, since it stores the messages for the length of
the request.
