Core concepts
Route Definitions
Learn how to define routes in Plasma
Routes are plain objects that satisfy the ServerRoutes type and can be consumed by createHttpClient.
| Field | Type | Description |
|---|---|---|
url | `/${string}` | Endpoint path (must start with /) |
params | z.ZodObject | Query parameters schema — enables validation and coercion |
apiPayload | z.ZodObject | Request body schema — validated before the request is sent |
clientInput | z.ZodObject | Input schema for the UI layer (e.g. form validation) — not sent to the API |
returns | unknown | Shape of the API response (type-only, not runtime) |
Example
import type { ServerRoutes } from '@crm/plasma'
import { } from 'zod'
const = {
"get-users": {
: `/api/users`,
: .({
: ..().(),
: ..().(),
}),
: {} as { : number; : string }[]
},
"get-profile": {
: `/api/users/profile`,
: {} as { : number; : string }
},
"create-user": {
: `/api/users`,
: .({
: .(),
: .(),
}),
: {} as { : number; : string }
}
} satisfies ServerRoutesimport { } from "./client";
const [, ] = await .("- get-users
- get-profile
- create-user
");