Seitu - Type-Safe Utilities
React

Hooks

useSubscription()

Use this hook to subscribe to a reactive value. Accepts a subscription object directly, or a factory function that is called only once on first render — subsequent renders reuse the cached subscription unless dependency array changes.

Examples

Inline subscription

/app/page.tsx
'use client'

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

export default function () {
  const  = (() => ({
    : 'sessionStorage',
    : 'test',
    : 0,
    : .(),
  }))

  return <>{}</>
}

Instance outside of component

/app/page.tsx
'use client'

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

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

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

Subscription with selector

/app/page.tsx
'use client'

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

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

export default function () {
  // Usage with selector, re-renders only when count changes
  const  = (, { :  => . })

  return <>{}</>
}

Ref example

/app/page.tsx
'use client'

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

export default function () {
  const  = React.<HTMLDivElement>(null)
  const  = (() => ({ : () => ., : 'vertical' }))

  return (
    < ={}>
      {(..)}
    </>
  )
}

On this page