Understanding the proxy boundary
When you rename a backend command property, how do you find the React components that still send the old name? Arc generates TypeScript proxies from backend declarations so that regeneration and frontend type-checking can identify those callers.
The proxy boundary is that generated contract between the backend and its consumers. You maintain the backend declaration rather than a second set of TypeScript request and response shapes. The example below follows an author-registration command across the boundary, then changes a property to show what the compiler catches.
One source of truth
Section titled “One source of truth”The backend declaration defines the contract used to generate the proxy. In the C# example below, the RegisterAuthor record defines the shape; JVM, TypeScript, and Go backends use their own declarations and generators. Change the declaration and regenerate to update the frontend types.
Generating from the same types catches structural drift at compile time when you rebuild and type-check both sides. It does not prove that a deployed client matches a deployed server, that runtime serialization customizations agree, or that build-time routes match runtime configuration. Those still need integration checks.
Walk the boundary
Section titled “Walk the boundary”- Write the slice on the backend. A command is a record (C#), a data class (Kotlin), or a decorated class (TypeScript) with a handler on it. This standalone excerpt uses the tutorial’s domain types, imports, and provider setup:
[Command]public record RegisterAuthor(AuthorId Id, AuthorName Name){ public Task Handle(IMongoCollection<Author> authors) => authors.InsertOneAsync(new Author(Id, Name));}@Commandpublic record RegisterAuthor(AuthorId id, AuthorName name) { public void handle(@FromServices AuthorRepository authors) { authors.save(new Author(id, name)); }}@Commanddata class RegisterAuthor(val id: AuthorId, val name: AuthorName) { suspend fun handle(@FromServices authors: AuthorRepository) { authors.save(Author(id, name)) }}import { field } from '@cratis/fundamentals';import { command, inject } from '@cratis/arc.core';
@command()export class RegisterAuthor { @field(AuthorId) id!: AuthorId; @field(AuthorName) name!: AuthorName;
@inject(AuthorRepository) handle(authors: AuthorRepository): Promise<void> { return authors.save({ id: this.id, name: this.name }); }}-
Configure and generate. Each backend discovers commands, queries, referenced types and supported validation rules from its own declarations. Generation is not an automatic step of every build; configure and run the appropriate backend tool.
On C#, install
Cratis.Arc.ProxyGenerator.Buildand setCratisProxiesOutputPathas in generator setup, then rundotnet build -c Debug. An MSBuild target runs after the build and invokes a post-build executable that inspects the compiled assembly and its PDB — it is not a Roslyn source generator. Without an output path the target does nothing, which is also how you skip generation on a second build.On Kotlin and Java, apply the
io.cratis.arcGradle plugin and configurecratisArc { proxies { } }as in TypeScript proxies. A KSP annotation processor runs as part of compilation and records what it found in an artifact manifest, and thegenerateArcProxiesGradle task turns that manifest into TypeScript.On TypeScript,
arc-proxygeneratorreads backend TypeScript source with--projectand--artifacts, and writes client proxies and optionally server metadata. Run your application’s generation script when declarations change; see TypeScript generator setup. That backend has its own capability reference, not a guarantee of parity with C# or JVM.On Go, follow TypeScript generation for the explicit metadata and typed adapter workflow. Its parity reference separates supported generated-client checks from unverified browser and React behavior; the tabs here do not include a Go example.
Namespace folders, source-file placement, and index output depend on each backend’s generator configuration.
-
Import the proxy in React. The generated class supplies the command’s typed properties and execution behavior. This form fragment assumes the frontend imports, providers, and per-operation
idstate from the first-slice tutorial:import { RegisterAuthor } from './Authors/RegisterAuthor'; // generated// Form fragment: retain the imports/providers and per-operation id state// from the first-slice tutorial; mount a new dialog instance per registration.<CommandDialog<RegisterAuthor> command={RegisterAuthor} title="Add author" initialValues={{ id }}><InputTextField<RegisterAuthor> value={i => i.name} title="Name" /></CommandDialog>
What keeps it honest
Section titled “What keeps it honest”Suppose you rename the command’s name property to fullName:
[Command]public record RegisterAuthor(AuthorId Id, AuthorName FullName) // was Name{ public Task Handle(IMongoCollection<Author> authors) => authors.InsertOneAsync(new Author(Id, FullName));}@Commandpublic record RegisterAuthor(AuthorId id, AuthorName fullName) { // was name public void handle(@FromServices AuthorRepository authors) { authors.save(new Author(id, fullName)); }}@Commanddata class RegisterAuthor(val id: AuthorId, val fullName: AuthorName) { // was name suspend fun handle(@FromServices authors: AuthorRepository) { authors.save(Author(id, fullName)) }}import { field } from '@cratis/fundamentals';import { command, inject } from '@cratis/arc.core';
@command()export class RegisterAuthor { @field(AuthorId) id!: AuthorId; @field(AuthorName) fullName!: AuthorName; // was name
@inject(AuthorRepository) handle(authors: AuthorRepository): Promise<void> { return authors.save({ id: this.id, name: this.fullName }); }}Regenerate the proxy and type-check the frontend. The proxy now has fullName where it used to have name, so TypeScript rejects the form’s old property accessor:
// This line stops compiling until you fix it:<InputTextField<RegisterAuthor> value={i => i.name} title="Name" />// ^^^^ Property 'name' does not exist on RegisterAuthorUpdate the accessor to the new property before running the form. This catches a structural mismatch without opening the browser. It does not check whether a rename changes the meaning of the field or whether older deployed clients still need the old contract.
What gets generated
Section titled “What gets generated”A configured C# generator build can emit these contracts. Use the backend-specific guides above for JVM and TypeScript output.
| Output | What the consumer uses |
|---|---|
| Commands | A class to instantiate and execute or hand to CommandDialog, with route, query-string, and body parameters represented as typed properties. |
| Queries | A proxy with React hooks and typed result state. Observable hooks subscribe to an emitting source and re-render on updates. |
| Types and enums | The referenced shapes used by command and query contracts, including nested data. |
| Identity details | The application’s custom identity type for frontend consumers. |
Each has a detailed reference: Commands, Queries, and Identity details. The frontend proxy-generation guide shows the generated TypeScript for each, with the .use() and useSuspense() hooks.
The transport disappears too
Section titled “The transport disappears too”The proxy also handles the request, so a component can execute RegisterAuthor or call AllAuthors.use() without constructing the URL or opening a socket. You still configure the backend address, headers, and live-query transport in Arc.
A regular query makes an HTTP request. An observable query streams over WebSocket or Server-Sent Events (SSE), selected with the queryTransportMethod prop on the <Arc/> context component. When you need a snapshot instead of a subscription, call perform() on the same observable proxy:
const [authors] = AllAuthors.use(); // live — streams over WebSockets or SSEconst snapshot = await new AllAuthors().perform(); // one-shot — a plain HTTP fetch, same proxyThe hook follows future emissions; perform() requests one result. For an observable snapshot, check readiness before treating missing data as an empty list. Some producers need wait-for-first-result configuration. Tune the live transport in the query configuration reference.
It’s a build step, not a runtime discovery call
Section titled “It’s a build step, not a runtime discovery call”Keep generation in the development workflow:
- You never edit a generated file. Change the backend declaration and regenerate; TypeScript projects may commit generated proxies alongside the source.
- On C#, the generator tracks what it made and removes files for commands or queries you delete. See File index tracking; the TypeScript generator also limits stale deletion to files it owns.
- The sequencing matters: generate proxies from updated backend declarations, then type-check the frontend. C# requires a successful Debug build first; the TypeScript generator reads source with the project configuration.
Why this is the thing that matters
Section titled “Why this is the thing that matters”Use the generated boundary to make backend contract changes visible to React callers during development. Keep integration checks for deployed versions, serialization, and runtime routing; those sit outside what TypeScript can prove.
To follow the same path in an application, build your first command and query, then wire it into React. After it works, rename a property, regenerate, and use the frontend type-check to find the affected consumer.