• Docs
  • Blog
    • 0.24.0

    • Switch to dark mode
    Get Started
    Components
    Styling
    Theming

    Concepts

    OverviewCompositionTesting

    Layout

    Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrap

    Components

    AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

    Utilities

    Feature FlagsForLocal StoragePortalShowsplitPropsTheme

    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