Video wird geladen...
Video konnte nicht geladen werden
Been using a similar pattern for a long time in the Next.js, but now with the app router we can also add a loader function that's executed in a server component. (Thanks Ryan Florence for the inspiration) ✅ Infer/validate params/searchParams from Zod schema. ✅ Infer data
22,573 Aufrufe • vor 2 Jahren •via X (Twitter)
10 Kommentare

Eelco Wiersmavor 2 Jahren
@ryanflorence Source code here:

Kyle Gillvor 2 Jahren
That create page function looks 👌

Eelco Wiersmavor 2 Jahren
Thanks Kyle!

Chris Ribeirovor 2 Jahren
@nextjs @ryanflorence Look nice! CreatePage is a public library?

Eelco Wiersmavor 2 Jahren
@nextjs @ryanflorence Yeah will release it in the next days 👌

Renato Ribeirovor 2 Jahren
@nextjs @ryanflorence What happens if zod can't parse params/searchParams? It will pass down type as `z.infer<T> | undefined`, it will throw or it will show a pre-defined error ui page?

Eelco Wiersmavor 2 Jahren
@nextjs @ryanflorence Right now it will throw and render error.tsx if it exists. But other options like a safe mode is also a consideration.

JB Hutchvor 2 Jahren
@nextjs @ryanflorence Ooh I like this!

Dalevor 2 Jahren
@nextjs @ryanflorence Oh this is a great idea!

Chris Eaglevor 2 Jahren
@nextjs @ryanflorence I like this

