Skip to content

har4s/use-local-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 });
  // ...
};

About

A React Hook for using Browser Local Storage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors