Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-flash-messages

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-flash-messages

One-time cookie-based flash messaging library for next.js.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

next-flash-messages

One-time cookie-based flash messaging library for next.js.

npm

Installation

$ npm install next-flash-messages

Usage

The next-flash-messages allows you to temporarily store messages in one request and retrieve them for display in a subsequent request.
This library stores flash message in the cookie.

import React from 'react'
import { withFlashMessages } from 'next-flash-messages'

class IndexPage extends React.Component {

  render() {
    const { flashMessages } = this.props

    // To get all flashed messages by category.
    const messages = flashMessages.get('flash message category')

    return (
      <div>
        { (() => {
          let i = 0
          if (messages.length > 0) {
            return messages.map((message) => {
              i++
              return (<p key={`msg-${i}`}>{`${i}: ${message[1]}`}</p>)
            })
          } else {
            return null
          }
        })() }
        <a onClick={ () => {
          // Set flash message with category.
          flashMessages.set('flash message strings.', 'flash message category')
        } }>Set flash message</a>
      </div>
    )
  }
}

export default withFlashMessages(IndexPage)

License

next-flash-messages is licensed under MIT License.
See LICENSE for more information.

Keywords

FAQs

Package last updated on 04 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc