Standard Schema Validation
Use Zod, Valibot, ArkType, or any Standard Schema library. No vendor lock-in, no adapters.
Validated inputs, middleware chains, builder pattern, and optimistic updates. Works with Zod, Valibot, and ArkType through Standard Schema.
Define a validated server action:
// server/api/todos.post.ts
import { z } from 'zod'
export default defineAction({
input: z.object({
title: z.string().min(1, 'Title is required'),
}),
handler: async ({ input }) => {
return await db.todo.create({ data: { title: input.title } })
},
})Call it from any component:
<script setup lang="ts">
const { execute, data, error, status } = useAction<
{ title: string },
{ id: number; title: string }
>('/api/todos')
async function addTodo() {
await execute({ title: 'Buy milk' })
}
</script>
<template>
<button @click="addTodo" :disabled="status === 'executing'">
Add Todo
</button>
<p v-if="data">Created: {{ data.title }}</p>
<p v-if="error" class="error">{{ error.message }}</p>
</template>You get validated input, typed handler parameters, reactive state management, and a consistent error format -- with zero configuration.