next-flash

1.0.2 • Public • Published

Flash

Flash messages for next.js. Works on both the client and the server.

Example

import flash from 'next-flash';
 
export default class Page extends Component {
  static async getInitialProps (ctx) {
    return flash.get(ctx) || {}
  }
 
  create () {
    flash.set({ name: 'matt' })
  }
 
  render () {
    return (
      <div>
        <Head>
          <title>Flash messages in Next</title>
          <meta name='viewport' content='width=device-width, initial-scale=1' />
        </Head>
        { this.props.name ? <div>FLASH MESSAGE {this.props.name}</div> : <div /> }
        <button onClick={() => this.create()}>Create flash message</button>
        <br />
        <Link href={`/?${Date.now()}`}>Client-Side Route</Link>
      </div>
    )
  }
}

Installation

yarn add next-flash

License

MIT

Dependents (0)

Package Sidebar

Install

npm i next-flash

Weekly Downloads

74

Version

1.0.2

License

MIT

Last publish

Collaborators

  • mattmueller