module-client
/module-client
Create or use a <name>-client package (modules/<name>/client): the typed tRPC hooks another module's browser reads. Use when someone says 'read another module's data in the browser', 'prompt-client', 'dataset-client', 'a client package', 'createModuleApi', 'ContractApiMap', 'derived tRPC client', 'browser wire', 'httpLink', 'request batching', 'the tRPC client in the browser', 'AppRouter in the UI', or 'can my screen call another module's procedure'. Teaches the record (ARCHITECTURE.md section 2 wire row, 3.4, 10).
- Author
- langwatch ↗
- Repository
- langwatch ↗
- Licence
- Apache-2.0
- Last repository change
- 27.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
What it does and when to use it
Create or use a <name>-client package (modules/<name>/client): the typed tRPC hooks another module's browser reads. Use when someone says 'read another module's data in the browser', 'prompt-client', 'dataset-client', 'a client package', 'createModuleApi', 'ContractApiMap', 'derived tRPC client', 'browser wire', 'httpLink', 'request batching', 'the tRPC client in the browser', 'AppRouter in the UI', or 'can my screen call another module's procedure'. Teaches the record (ARCHITECTURE.md section 2 wire row, 3.4, 10).
Triggers from the description
Arguments
/module-client <module name or data question>
Original author description
Create or use a <name>-client package (modules/<name>/client): the typed tRPC hooks another module's browser reads. Use when someone says 'read another module's data in the browser', 'prompt-client', 'dataset-client', 'a client package', 'createModuleApi', 'ContractApiMap', 'derived tRPC client', 'browser wire', 'httpLink', 'request batching', 'the tRPC client in the browser', 'AppRouter in the UI', or 'can my screen call another module's procedure'. Teaches the record (ARCHITECTURE.md section 2 wire row, 3.4, 10).
How it works
- The wire, in one picture
- Rules that matter
- Worked example
- Traps
SKILL.md preview
---
name: module-client
description: "Create or use a <name>-client package (modules/<name>/client): the typed tRPC hooks another module's browser reads. Use when someone says 'read another module's data in the browser', 'prompt-client', 'dataset-client', 'a client package', 'createModuleApi', 'ContractApiMap', 'derived tRPC client', 'browser wire', 'httpLink', 'request batching', 'the tRPC client in the browser', 'AppRouter in the UI', or 'can my screen call another module's procedure'. Teaches the record (ARCHITECTURE.md section 2 wire row, 3.4, 10)."
user-invocable: true
argument-hint: "<module name or data question>"
---
# `<name>-client`: modules share data, not code
Read `dev/docs/ARCHITECTURE.md` §2 (the Web row), §3.4 ("No kits; data through
clients") and §10 (the cache and wire rulings). Exemplars:
`modules/dataset/client` (about 30 lines of source) and `modules/prompt/client` (the same
derived client plus lent drawers and prompt-studio tokens). A module with tRPC procedures gets `modules/<name>/client`, package
`@langwatch/<name>-client`. A module nothing else reads has none
(integration, §3).
## The wire, in one picture
```
contract (<name>Trpc) --ContractApiMap--> createModuleApi() --> hooks (useQuery, useMutation, useUtils)
|
@langwatch/browser owns the one browser client: httpLink + SSE link + query client
```
- `@langwatch/api/web` derives the typed client from the contract's declarations.
- `@langwatch/browser` owns the transport (one client per application,
`packages/browser/src/wire/transport.ts`), the SSE subscription link and the
query client. Only a client package and a screen's `behavior/` import it.
A design-system component fetches nothing.
- The browser calls no REST.
## Rules that matter
Each rule lives in the record or an ADR; this table only points at it.
| Rule | Source |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------- |
| Derived from `ContractApiMap<typeof <name>Trpc>`, never hand-written, never `AppRouter` | ADR-130 (`130-the-api-router-type-is-declared`) |
| Holds the derived hooks plus a few thin ones and the owner's lent tokens, never a component | §3.4, §10.1 |
| Imports its own contract, `@langwatch/module` (for the tokens it lends), `@langwatch/api/web`, `@langwatch/browser-host` and React only; a two-module hook lives in the screen | §2, §3.4 |
| Read only by browser packages and apps/ui; the linters' `client` role refuses any other reader | §2, §17 |
| One call per request over `httpLink`; no batching, the server refuses it | §10 |
| Every read is mirrored to disk by default (`UI_QUERY_MIRROR_EXCLUDED` names the exceptions); no per-read `staleTime`; no credential in a query | §10, §10.2 |
| One entity, one key: opaque id plus tenant scope; hints never enter a key | §10.2 |
| A procedure another module owns sits in a `BorrowedProcedures` type: debt, not a pattern | (convention; the record is silent) |
## Worked example
```ts
// modules/prompt/client/src/prompt-client.ts
import {
type ContractApiMap,
createModuleApi,
type ModuleApi,
type OutputsFromMap,
} from "@langwatch/api/web";
import type { promptTagTrpc, promptTrpc } from "@langwatch/prompt-contract";
type PromptApiMap = ContractApiMap<typeof promptTagTrpc> & ContractApiMap<typeof promptTrpc>;
export const promptClient: ModuleApi<PromptApiMap> = createModuleApi<PromptApiMap>();
export type PromptOutputs = OutputsFromMap<PromptApiMap>; // PromptInputs likewise
```
The minimal `src/index.ts` (dataset's) re-exports the client and its output and input types and
nothing else. Prompt's also exports its lent drawers and prompt-studio tokens, so its
`package.json` adds `@langwatch/module` to `@langwatch/api` and `@langwatch/prompt-contract`. Each
has `main` and one `exports["."]`. A consuming browser package lists
`@langwatch/prompt-client` and calls `promptClient.<proc>.useQuery(...)`
inside its own `behavior/` hook; its declaration still names its own api
(`.withApi(...)`, §10). There is no per-contract cache policy: every read is
mirrored by default (§10.2), and `TrpcCachePolicy` is deleted (§15).
To add one: copy `modules/dataset/client`, rename, point `ContractApiMap` at
every `*Trpc` object the contract exports, run `pnpm sync:references`
(new workspace package) and `pnpm generate:modules` if the catalogue changed.
Not every module with a contract has a client. There are about thirty across core and
Enterprise modules; find one with `ls modules/*/client enterprise/modules/*/client`, and a
module's page in `modules/README.md` says whether it has one.
## Traps
- **Importing another module's `-browser` package for its hook.** It is closed.
Use its client.
- **Putting a component in a client** because two modules want it. It goes to
`design-system` taking props or a query result, or the owner lends it by a token
declared in its client (§10.1).
- **Copying server data into `useState` or a store.** It stays in React Query
(`query-data-in-state` lint, ADR-169).
- **Calling a procedure by path from a typed hook's key.** A surface too wide
for a typed hook uses the shell's `UiRpc`; never re-enter the cache under the
key being resolved (§10).
- Host-service wiring, lending and entitlement are not here: §3.3, §10.1 and
the `frontend` skill. Where the hook is used: `browser-module`.
Versions
The database has no other skills named module-client.
Database snapshot: 13.11.2026 · package version 0ad7251cced0 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100cross-package-types
Type flow patterns for tRPC + Prisma monorepos. Covers AppRouter type inference across shared, server, and client packages. Use when setting up types, fixing type errors across packages, or understanding the type chain. - 85tRPC
Expert guidance for tRPC (TypeScript Remote Procedure Call) including router setup, procedures, middleware, context, client configuration, and Next.js integration. Use this when building type-safe APIs, integrating tRPC with Next.js, or implementing client-server communication… - 100browser-module
Write or change a module's browser half (modules/<name>/browser): a screen, a drawer, a section, a hook, a slice of browser state, a cached read, or a data fetch in the UI. Use when someone says 'add a screen', 'add a drawer', 'where does this component go', 'browser state',… - 90trpc
Apply when writing tRPC routers, procedures, or router tests. Esposter's tRPC conventions — how a router, a procedure and its input are laid out, named and guarded, and how a client calls one. - 100contract
Write or change a module's contract package (modules/<name>/contract): the `*Api` interface and moduleApi token, Zod schemas with z.infer, HandledError subclasses and their codes, the tRPC declarations (defineTrpcContract), REST wire schemas, method verbs (get/find/list,… - 100trpc
tRPC builds end-to-end type-safe TypeScript APIs without schemas or code generation: the server defines procedures, the client calls them with full type inference. Use when someone asks to "add tRPC", "set up a tRPC router", "call my API with type safety", "use tRPC with React…