@void-snippets/react

@void-snippets/react

TanStack Query factories, Socket.IO hooks, routing contract, and utilities.

#What is in this package?

@void-snippets/react contains everything React-specific: three factories that generate typed hooks from your definitions, and five standalone utility hooks.

typescript
import {
  createResourceHooks,
  createSocketHooks,
  createRouteContract,
  defineRoute,
  useTypedParams,
  useTypedSearchParams,
  useAlertMessage,
  useAsyncState,
  useCallTimer,
  useModal,
  usePagination,
} from '@void-snippets/react';

#Factories

FactoryOutput
createResourceHooks(key, service, options?)useList, useGet, useMutations, useInfinite
createSocketHooks(socket)useSocketEmit, useSocketListener, useSocketConnection
createRouteContract(tree)A typed route tree with build() on every leaf

#Routing hooks

HookWhat it reads
useTypedParams(route)URL path segments — /users/:userId{ userId: string }
useTypedSearchParams(route)Query string — ?page=1&sort=asc → typed object

#Standalone utility hooks

HookWhat it manages
useAlertMessage(duration?)Alert/notification lifecycle — text, severity, visibility, auto-hide
useAsyncState()Generic async state machine with execute(), reset(), and status flags
useCallTimer(startedAt)Live elapsed "MM:SS" counter, auto-cleaned on unmount
useModal()Create/edit modal state with openCreateModal, openEditModal, closeModal
usePagination(page, limit)Page and limit state with ready-to-spread queryParams