Seitu - Type-Safe Utilities
Web

Web Storage Value

createWebStorageValue()

Creates a reactive handle for a localStorage or sessionStorage instance.

Examples

Vanilla

session-storage.ts
import {  } from 'seitu/web'
import * as  from 'zod'

const  = ({
  : 'sessionStorage',
  : 'token',
  : .().(),
  : null,
})

.() // null
.('abc')
.() // 'abc'
.(.)

With storage

session-storage.ts
import { ,  } from 'seitu/web'
import * as  from 'zod'

const  = ({
  : 'sessionStorage',
  : { : .(), : .() },
  : { : 0, : '' },
})

const  = ({
  : ,
  : 'count',
})

.() // 0
.(1)
.() // 1

React

page.tsx
'use client'

import {  } from 'seitu/web'
import {  } from 'seitu/react'
import * as  from 'zod'

const  = ({
  : 'sessionStorage',
  : 'count',
  : .(),
  : 0,
})

export default function () {
  const  = ()
  return (
    <>
      <>{}</>
    </>
  )
}

On this page