import { createFileRoute } from "@tanstack/react-router"
import { createServerFn } from "@tanstack/start"
import { parseWithZod } from "@conform-to/zod"
import { z } from "zod"
const schema = z.object({
username: z.string(),
})
const serverFn = createServerFn({ method: "POST" })
.validator((data: FormData) => data)
.handler(async (options) => {
const submission = parseWithZod(options.data, { schema })
return submission.reply() // Throws the type error
})
export const Route = createFileRoute("/")({
component: Home,
})
function Home() {
return (
<form
action={serverFn.url}
method="post"
encType="multipart/form-data"
>
<input type="text" name="username" />
<button>Submit</button>
</form>
)
}
import { createFileRoute } from "@tanstack/react-router"
import { createServerFn } from "@tanstack/start"
import { parseWithZod } from "@conform-to/zod"
import { z } from "zod"
const schema = z.object({
username: z.string(),
})
const serverFn = createServerFn({ method: "POST" })
.validator((data: FormData) => data)
.handler(async (options) => {
const submission = parseWithZod(options.data, { schema })
return submission.reply() // Throws the type error
})
export const Route = createFileRoute("/")({
component: Home,
})
function Home() {
return (
<form
action={serverFn.url}
method="post"
encType="multipart/form-data"
>
<input type="text" name="username" />
<button>Submit</button>
</form>
)
}