# simple-express-flash

> A simple ExpressJS flash middleware

Latest version **1.0.0** (published 2015-04-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-express-flash
pnpm add simple-express-flash
yarn add simple-express-flash
bun add simple-express-flash
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-04-20 |
| First published | 2015-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Eugene Kuzmenko |
| Maintainers | aljey |
| Keywords | simple, expressjs, session, flash, messages |

## Links

- npm: https://www.npmjs.com/package/simple-express-flash
- Repository: https://github.com/thealjey/simple-express-flash
- Homepage: https://github.com/thealjey/simple-express-flash#readme
- Issues: https://github.com/thealjey/simple-express-flash/issues
- npm.io page: https://npm.io/package/simple-express-flash

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-04-20

## README

# simple-express-flash
*A simple ExpressJS flash middleware*

This middleware adds a dead simple flash method to the request object and makes it also available inside your templates.

### Install

    npm i simple-express-flash --save
### Configure

    import express from 'express';
    import session from 'express-session';
    import flash from 'simple-express-flash';
    
    express()
      .use(session({
        resave: false,
        saveUninitialized: false,
        secret: 'my keyboard cat was replaced by a dog'
      }))
      .use(flash);
### And use

    app.use(function (req) {
      /**
       * Store a message
       * @param {string} key
       * @param {string} message
       * @returns {string[]} a collection of set messages
       */
      req.flash('key', 'message text');
       
      /**
       * Retrieve an array of messages by key, removing them from storage
       * (such is the nature of flash messages, they disappear in a "flash")
       * @param {string} key
       * @returns {string[]}
       */
      req.flash('key');
       
      /**
       * Retrieve all messages
       * @example
       * // returns {key: ['message text']}
       * @returns {Object}
       */
      req.flash();
    });
The exact same function can be used inside of your templates

    each message in flash('error')
      .alert.alert-danger(role='alert')= message

---
_Source: https://npm.io/package/simple-express-flash · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
