@anvil-js/client
v0.0.3
Published
Anvil API client — tRPC router types, Zod schemas, React Query hooks and the Essential WS client.
Readme
@anvil-js/client
Typed client for the Anvil API: the tRPC router types, Zod schemas, TanStack Query React hooks, and the Essential WebSocket client.
Works in ESM and CommonJS — usable in a bundler, a modern import
script, or a plain require() Node script (e.g. a Discord bot). The root
entry has no React dependency.
npm i @anvil-js/client
# only if you use the React hooks (@anvil-js/client/react):
npm i react @tanstack/react-query @trpc/react-query// CommonJS (Discord bot, plain script)
const { createAnvilClient } = require('@anvil-js/client');// ESM / TypeScript
import { createAnvilClient } from '@anvil-js/client';Entry points
| Import | Contents |
| --- | --- |
| @anvil-js/client | tRPC client factory, router type (AppRouter), core types |
| @anvil-js/client/react | TanStack Query provider + typed hooks |
| @anvil-js/client/schemas | Zod schemas (auth, builds, social, cosmetics, …) |
| @anvil-js/client/server | server-side router type helpers |
| @anvil-js/client/ws | Essential binary WS client + codec |
import { createAnvilClient } from '@anvil-js/client';
const client = createAnvilClient({
baseUrl: 'https://anvil.my/v1',
getToken: async () => localStorage.getItem('anvil.jwt') ?? undefined,
});ESM-only. Published from the Anvil monorepo (packages/client).
