Seitu - Type-Safe Utilities
Web

Web Storage

createWebStorage()

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',
  : {
    : .().(),
    : .({ : .(['light', 'dark']) }),
  },
  : { : null, : { : 'light' } },
})

.() // { token: null, preferences: { theme: 'light' } }
.({ : 'abc' })
.() // { token: 'abc', preferences: { theme: 'light' } }
.(.)

React

page.tsx
'use client'

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

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

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

On this page