I have been doing some tutorials around nodejs. One tutorial mentions a library called “connect-flash” that lets you set “flash data”.
I have never heard of this term before could someone please define this? (I found the readme rather unhelpful)
It’s a type of user data that you show once and then destroy. Usually a top alert like “Your action has been successful” or similar.
By its nature it’s dynamic, so it’s saved in the user session and displayed in the very first rendered page, then discarded.
Taken from the doc page for the connect-flash library which seems fairly self-explanatory:
The flash is a special area of the session used for storing messages.
Messages are written to the flash and cleared after being displayed to
the user. The flash is typically used in combination with redirects,
ensuring that the message is available to the next page that is to be
This middleware was extracted from Express 2.x, after Express 3.x
removed direct support for the flash. connect-flash brings this
functionality back to Express 3.x, as well as any other
middleware-compatible framework or application. +1 for radical
Flash messages are stored in the session. First, setup sessions as
usual by enabling cookieParser and session middleware. Then, use flash
middleware provided by connect-flash.