next-persist-state

1.0.5 • Public • Published

next-persist-state

Localstorage for next js

NPM JavaScript Style Guide

Install

npm install --save next-persist-state

Usage

import React from "react";
import usePersistState from "next-persist-state";

const App = () => {
  /** add unique key so that specific state value can be retrieved */
  const [value, setValue, clearValue] = usePersistState(
    "SAMPLE_KEY",
    "Hello World!"
  );

  return (
    <div>
      <div>{value}</div>
      <div>
        <button onClick={() => setValue("New Value")}>set value</button>
        <button onClick={() => clearValue()}>clear value</button>
      </div>
    </div>
  );
};

export default App;

License

MIT © khantwaikyaw


This hook is created using create-react-hook.

Readme

Keywords

none

Package Sidebar

Install

npm i next-persist-state

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

636 kB

Total Files

22

Last publish

Collaborators

  • khantwaikyaw11