@har4s/use-local-storage
TypeScript icon, indicating that this package has built-in type declarations

0.3.4 • Public • Published

Use Local Storage

A React Hook for using Browser Local/Session Storage

Installation

npm install @har4s/use-local-storage

or

yarn add @har4s/use-local-storage

Usage

import { useLocalStorage } from '@har4s/use-local-storage';
// or import { useSessionStorage } from '@har4s/use-local-storage';

export const Example = () => {
  // ...
  const [something, setSomething] = useLocalStorage('key', 'fallback');
  // or const [something, setSomething] = useSessionStorage('key', {...});
  // or const [something, setSomething] = useLocalStorage('key', 'fallback',{ persistent:false });
  // ...
};

Package Sidebar

Install

npm i @har4s/use-local-storage

Weekly Downloads

8

Version

0.3.4

License

MIT

Unpacked Size

15.6 kB

Total Files

16

Last publish

Collaborators

  • har4s