Guides
Schema Validation
Learn how to add schema validation to your Aura Router endpoints using popular validation libraries.
Schema validation is an optional configuration in createEndpoint and createEndpointConfig. It enables runtime validation for headers, params, searchParams, and body — verifying the incoming data and giving the endpoint's request context full type safety.
import { z } from "zod"
import { createEndpoint } from "@aura-stack/router"
export const endpoint = createEndpoint(
"POST",
"/auth/signIn",
async (ctx) => {
const { username, password } = ctx.body
return Response.json({ message: "Successful Login" })
},
{
schemas: {
body: z.object({
username: z.string(),
password: z.string(),
}),
},
}
)Installation
To add schema validation support, install the corresponding validation library alongside @aura-stack/router. Supported validators are Zod, TypeBox, Valibot, and ArkType.
npm install zodnpm install typeboxnpm install valibotnpm install arktype