Using Zod Form Validation and Server Actions in NextJs with useFormState Hook

Поділитися
Вставка
  • Опубліковано 22 лис 2024

КОМЕНТАРІ • 15

  • @adomakins
    @adomakins Місяць тому +1

    Thank you for the video!
    Forms feel so complicated and you broke it down super simply which was awesome

  • @MaximeOnDev
    @MaximeOnDev Місяць тому +1

    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

    • @CodingAfterThirty
      @CodingAfterThirty  Місяць тому

      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
      @MaximeOnDev Місяць тому

      @@CodingAfterThirtyi love how clean the server action look like. And it broke my heart to switch from action to a onSubmit 😭

    • @CodingAfterThirty
      @CodingAfterThirty  Місяць тому

      @@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.

  • @noobboiii007
    @noobboiii007 2 місяці тому +1

    Hey I have question can we deploy Strapi cms in Hostinger VPS server?

    • @CodingAfterThirty
      @CodingAfterThirty  2 місяці тому

      I haven't used Hostinger, but any service that allows you to spin up a VPS would support Strapi deployment.

  • @kennethlau8108
    @kennethlau8108 Місяць тому

    Can we have a github link for this ? Perhaps an example code that reflects this. Thanks

    • @CodingAfterThirty
      @CodingAfterThirty  21 день тому

      Sorry it took me a bit to reply, but here is the repo for the project. github.com/PaulBratslavsky/strapi-5-next-15-store

  • @mystupidbrain5299
    @mystupidbrain5299 2 місяці тому +1

    First

  • @adamovicslobodan3331
    @adamovicslobodan3331 Місяць тому

    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?

    • @CodingAfterThirty
      @CodingAfterThirty  Місяць тому

      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.

    • @adamovicslobodan3331
      @adamovicslobodan3331 Місяць тому +1

      @@CodingAfterThirty This was for my testing purpose...beacuse I saw on some video that the guy tested also server actions while JS i disabled.

    • @CodingAfterThirty
      @CodingAfterThirty  Місяць тому

      @@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.