DocsBlog
  • 0.25.3

  • light

    dark

    system

    Switch mode
  • Cerberus

    Acheron

    Elysium

Get Started
Components
Styling
Theming

Concepts

OverviewCompositionTesting

Layout

Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFrameHighlightJSON Tree ViewLocaleLocal StoragePortalPresenceShowsplitPropsTheme

Local Storage

Simple helpers for managing local storage in your React applications.

  • npm
  • source
import { getLocalStorage, setLocalStorage } from '@cerberus/react'

Usage

page.tsx
'use client';
import { getLocalStorage } from '@cerberus/react'
import { useState } from 'react'
export default function Page() {
const [value, setValue] = useState<string>('')
// You have to wait until the component is mounted to
// have access to the local storage
useEffect(() => {
const value = getLocalStorage('key')
setValue(value)
}, [])
return (
<Text>
This is from local storage: {value}
</Text>
)
}

API

getLocalStorage

NameDefaultDescription
keyThe key that the value is saved under
defaultValueThe default value to return if the key does not exist in localStorage

setLocalStorage

NameDefaultDescription
keyThe key to save the value under
valueThe value to save in localStorage

On this page

  • Edit this page on Github
Cerberus Design System | Docs