@void-snippets
Overview
Stop rewriting the same loading states, error handlers, and URL builders. Define your data shape once — get typed hooks, sockets, and routing contracts for free.
#What is void-snippets?
Every CRUD feature you build ends up with the same boilerplate: fetch the list, track isLoading, handle the error, invalidate the cache after a mutation, build a URL string, parse query params. The code is not hard — it is just identical every time, and every copy is a chance for a slightly wrong convention or a missed edge case.
@void-snippets is that boilerplate, extracted once and made fully typed. You describe the shape of your data and the library generates the hooks, cache management, URL builders, and state machines for you.
#Three independent packages
| Package | Version | What it gives you |
|---|---|---|
@void-snippets/core | 0.3.0 | Branded ID types, shared interfaces, the catchError helper |
@void-snippets/client | 0.3.0 | Generic typed HTTP class — extend once per resource, get CRUD for free |
@void-snippets/react | 0.6.0 | TanStack Query hook factory, Socket.IO hook factory, typed routing contract, five utility hooks |
Install just the packages you need. @void-snippets/core has zero runtime dependencies. @void-snippets/client works in Vue, Node, or plain TypeScript. @void-snippets/react requires React 17+.
#How it fits together
your app
└── @void-snippets/react (useList, useMutations, createSocketHooks, …)
└── @void-snippets/client (ResourceService, configure, handleApiError)
└── @void-snippets/core (VSId, VSAdapters, catchError, shared types)You write:
- One type file —
Contact.Id,Contact.Base,Contact.Detail, payload types
- One service file —
class ContactsApiService extends ResourceService<…>
- One hooks file —
export const contactHooks = createResourceHooks('contacts', ContactsApis)
You get:
contactHooks.useList()— paginated list with three loading states
contactHooks.useGet(id)— single item, auto-disabled when id is absent
contactHooks.useMutations()— typed create, update, remove with auto cache invalidation
contactHooks.useInfinite()— load-more / infinite scroll
- All of the above with optimistic updates if you provide the cache-transform functions