Next.js Discord

Discord Forum

Validate data on serverside AppDir without actions

Answered
Oak apple gall wasp posted this in #help-forum
Open in Discord
Oak apple gall waspOP
Hi guys,

Do you how to validate form data on serverside without server actions ?
Answered by riský
I as more asking what you were using to get the data... as the only native ways are server actions or route handlers (in app dir, otherwise its only api routes)... but in those ones, you need to make your own custom method... this could be zod as suggested of just some if statements (zod i would say is better)
View full answer

7 Replies

Like with route handlers?
@riský Like with route handlers?
Oak apple gall waspOP
I was just interested if next.js had similar way for validating form data
Server Actions or Route Handlers are the only way.

In both of those you will probably have to use something like Zod
@Oak apple gall wasp I was just interested if next.js had similar way for validating form data
I as more asking what you were using to get the data... as the only native ways are server actions or route handlers (in app dir, otherwise its only api routes)... but in those ones, you need to make your own custom method... this could be zod as suggested of just some if statements (zod i would say is better)
Answer
Oak apple gall waspOP
Thank you guys… 👌 yeah I was using route handlers but was wondering if there was other ways besides actions which is beta for now unfortunately
Oak apple gall waspOP
yes indeed!