Standard Schema Support
BurgerAPI is not locked to Zod. Any schema library that follows the Standard Schema contract works through the same schema.ts convention, with no extra setup and no new dependency.
Libraries that implement Standard Schema include Valibot, ArkType, and Zod v4 itself.
Example with a Standard Schema library
api/products/schema.ts
import { object, string, number } from "valibot"; // or any ~standard library
export const POST = {
body: object({
name: string(),
price: number(),
}),
};
api/products/route.ts
import { defineRoute } from "burger-api";
import { POST as PostSchema } from "./schema";
export const POST = defineRoute(PostSchema, (ctx) => {
const { name, price } = ctx.validated.body;
return Response.json({ name, price });
});
How detection works
When a route is prepared, BurgerAPI picks the right connector for each schema:
- Zod is recognized first (it is the default provider).
- Any other library that exposes the Standard Schema contract (
~standard.validate) is used automatically. - If a schema is neither Zod nor a Standard Schema, BurgerAPI reports the error when the app starts.
Both Zod and a Standard Schema library can be used in the same app, even on different routes.
Rules
- The Standard Schema validator must be synchronous for request validation. An async validator causes an error at startup.
- A declared
bodyschema gates the media type: a non-JSON content type gets415 Unsupported Media Typebefore validation runs.ctx.validated.bodyis non-optional when the schema declaresbody. See Body Validation for the empty-body and missing-Content-Typerules. - Zod remains the recommended default because it is what BurgerAPI documents and the examples use.