next-flash

flash messages for next

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
next-flash
1.0.25 years ago6 years agoMinified + gzip package size for next-flash in KB

Readme

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

Example

```js 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