1.0.5 • Published 2 years ago

next-persist-state v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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.