Hey, nice video! But wouldn’t it be better to have both client-side and server-side validation? Right now, when a field is empty and you submit, we have to wait for the server response to get the error and make a useless POST request. If we also implement the Zod check on the client side, we would get the error immediately without waiting for the server response
Yeah, you can do that, too. I made a video on client-side validation in the past, but in this video, I wanted to focus on server action and show that you can do validation on the server. But in a real-world project, you can use a combination of both strategies. Although I don't mind just server-side validation.
@@MaximeOnDev Lol, I try to avoid any extra useState or useEffects in my projects. I almost want to do every action as a form and use server actions. But for better user UI experience sometimes you have no choice.
I have an issue when I disable JS in the browser. I call the action, it is handled inside the server function, and when I send data to the Strapi, once I refresh the page ( still JS is disabled ), it again sends the data to the Strapi. How to prevent sending same formData again and again to the Strapi from the server-side?
I will have to check it out and see. I did not test it with JS disabled. Are you expecting others to disable JS on your project? I am assuming it may have something to do with useFormState.
Thank you for the video!
Forms feel so complicated and you broke it down super simply which was awesome
Thank you. Glad you enjoyed it. 😀
Hey, nice video! But wouldn’t it be better to have both client-side and server-side validation? Right now, when a field is empty and you submit, we have to wait for the server response to get the error and make a useless POST request. If we also implement the Zod check on the client side, we would get the error immediately without waiting for the server response
Yeah, you can do that, too. I made a video on client-side validation in the past, but in this video, I wanted to focus on server action and show that you can do validation on the server.
But in a real-world project, you can use a combination of both strategies.
Although I don't mind just server-side validation.
@@CodingAfterThirtyi love how clean the server action look like. And it broke my heart to switch from action to a onSubmit 😭
@@MaximeOnDev Lol, I try to avoid any extra useState or useEffects in my projects.
I almost want to do every action as a form and use server actions.
But for better user UI experience sometimes you have no choice.
Hey I have question can we deploy Strapi cms in Hostinger VPS server?
I haven't used Hostinger, but any service that allows you to spin up a VPS would support Strapi deployment.
Can we have a github link for this ? Perhaps an example code that reflects this. Thanks
Sorry it took me a bit to reply, but here is the repo for the project. github.com/PaulBratslavsky/strapi-5-next-15-store
First
I have an issue when I disable JS in the browser. I call the action, it is handled inside the server function, and when I send data to the Strapi, once I refresh the page ( still JS is disabled ), it again sends the data to the Strapi. How to prevent sending same formData again and again to the Strapi from the server-side?
I will have to check it out and see. I did not test it with JS disabled. Are you expecting others to disable JS on your project? I am assuming it may have something to do with useFormState.
@@CodingAfterThirty This was for my testing purpose...beacuse I saw on some video that the guy tested also server actions while JS i disabled.
@@adamovicslobodan3331 hey can you link to one of the videos, I am curious if they were using useFormState.
I want to explore the topic a bit more.