I'm definitely using this library for all server actions now

Sdílet
Vložit
  • čas přidán 5. 05. 2024
  • My Products
    🏗️ WDC StarterKit: wdcstarterkit.com
    📖 ProjectPlannerAI: projectplannerai.com
    🤖 IconGeneratorAI: icongeneratorai.com
    📝 ThumbnailCritique: thumbnailcritique.com
    Useful Links
    💬 Discord: / discord
    🔔 Newsletter: newsletter.webdevcody.com/
    📁 GitHub: github.com/webdevcody
    📺 Twitch: / webdevcody
    🤖 Website: webdevcody.com
    🐦 Twitter: / webdevcody

Komentáře • 97

  • @JohnCanCode
    @JohnCanCode Před 2 měsíci +8

    Good find, buddy.
    A short vid like this explaining your page loading bar would be golden.

  • @NaniwaRocky
    @NaniwaRocky Před 2 měsíci

    Great stuff as always, can't wait for an in-depth video of your starter kit. As someone who does C# at work & js as a hobby i'm hoping you will add ci/cd with AWS ec2 or other for your starter kit . Many thx for your content!

  • @melquip7
    @melquip7 Před 2 měsíci +2

    This is actually really cool. Will use it for sure.

  • @filipfiser1045
    @filipfiser1045 Před 2 měsíci

    Great, I've implemented my own action wrapper, but this seems way cooler.

  • @SeibertSwirl
    @SeibertSwirl Před 2 měsíci +5

    Good job babe!

  • @CodingAfterThirty
    @CodingAfterThirty Před 2 měsíci +1

    Sick. Thanks for sharing.

  • @ShivGamer
    @ShivGamer Před 2 měsíci

    Lovely video, I just started using server actions and this will help me handle those. If possible could you make a video related to server actions? and if we should use them instead of regular API call. Thanks

  • @martijnjansen5388
    @martijnjansen5388 Před 2 měsíci

    Hey cool, thanks for sharing, this will definitely help.

  • @user-ik7rp8qz5g
    @user-ik7rp8qz5g Před 2 měsíci

    Since you mentioned zod, is there a good way to make it output errors in different locales?

  • @cas818028
    @cas818028 Před 2 měsíci

    In your implementation, in your middleware, does that mean every single request has to hit the db to get the current user?

  • @krj666
    @krj666 Před 2 měsíci

    Hi cody can you share how do you have multiple apps in one Next.js 14 project ?

  • @SonAyoD
    @SonAyoD Před 2 měsíci

    Great content as always bro. If you’re using convex db do you need server actions? And what web api or library are you using to get the user IP

    • @WebDevCody
      @WebDevCody  Před 2 měsíci

      No with convex you invoke their mutations and actions directly which has its own form of parsing / validation. The ip is just coming from inspecting the headers

  • @avijitchanda7944
    @avijitchanda7944 Před 2 měsíci

    Bro how you do rate limit can you please tell me

  • @yugaank100
    @yugaank100 Před 2 měsíci

    I mean, if you have auth in your application cant use just check if the certain individual exists and has proper access to the protected endpoint? Do you mean for open endpoints?

    • @WebDevCody
      @WebDevCody  Před 2 měsíci

      Yes, but I’m talking more about parsing input (like verify an email is actually an email format)

    • @yugaank100
      @yugaank100 Před 2 měsíci

      @@WebDevCody Understood, so something like safeParse?

  • @chrisrudman3495
    @chrisrudman3495 Před 8 dny

    Hey Cody, have you ditched this library now for ZSA? I saw you mention it in a more recent video. Thanks

    • @WebDevCody
      @WebDevCody  Před 8 dny

      Yes, I’ve been using zsa mainly.

  • @JakobRossner-qj1wo
    @JakobRossner-qj1wo Před 2 měsíci +3

    That looks very much like tRPC (Especially on the backend and client side)
    Server Actions do have many advantages but I think for most cases I will use tRPC (client side call)

    • @skyhappy
      @skyhappy Před 2 měsíci

      Server actions are unnecessary bloat. Just use a normal API endpoint

    • @JakobRossner-qj1wo
      @JakobRossner-qj1wo Před 2 měsíci

      @@skyhappy I dont think so, there are quite nice, especially with this helper. tRPC gives you typesafety and server actions allow you to make your form work even with JS disabled. There are more advantages for both of them but these are the most important ones for me.

    • @PhillipLippi
      @PhillipLippi Před 2 měsíci

      @@JakobRossner-qj1wo JS disabled, ok. Tell me how many digital projects you'll need JS disabled? maybe 1%? Lets be honest, it's 100% better using Client side for UX / UI purposes. It's not like your application will be heavy and unsafe for not using Server action

    • @alaskandonut
      @alaskandonut Před 14 dny

      @@JakobRossner-qj1woserver actions also give you type safety.

    • @JakobRossner-qj1wo
      @JakobRossner-qj1wo Před 14 dny

      @@alaskandonut that why they are better than normal APIs. That was mostly what we were discussing.

  • @Corey3D
    @Corey3D Před 17 dny

    Would you recommend still using this even after now that NextJS Middleware is executed on server actions as well? Or would it be "overdone" protection?

    • @WebDevCody
      @WebDevCody  Před 17 dny

      I don’t trust middleware for checking auth imo. To easily to misconfigure and leave a page or action exposed

    • @Corey3D
      @Corey3D Před 17 dny

      @@WebDevCody Thank you, yes I am too skeptical to use just a single solution. mainly due to my newbie NextJS knowledge, I usually protect every step with middleware, the page and actions too (now with using next-safe-action, thanks to you), Not sure if these many auth steps are good for the app overall but I guess more protection is better than none.

  • @imkir4n
    @imkir4n Před 2 měsíci

    yes im using it.

  • @ahmedhassan_saver
    @ahmedhassan_saver Před 29 dny

    Is there a repo containing your code ?
    i need to take a look at something
    this is outdated, right ?

  • @ESArnau
    @ESArnau Před 2 měsíci +1

    the idea of using this lib is to mostly use client forms instead of forms in server components, right? I see in docs they say "Functionality is limited in this case"

    • @WebDevCody
      @WebDevCody  Před 2 měsíci +1

      Yes I think so. I use client components for all my forms anyway

    • @ESArnau
      @ESArnau Před 2 měsíci

      @@WebDevCody why? Curious

    • @WebDevCody
      @WebDevCody  Před 2 měsíci +1

      @@ESArnau because often I need to show a toast, pop up a banner, show confetti, etc after a user clicks a button. You can’t really do that unless you add things into the query string to show a toast after revalidating the path.

    • @ESArnau
      @ESArnau Před 2 měsíci

      @@WebDevCody I see, and why would you use then this next-safe-action approach instead of trpc?

  • @YuraZavadenko
    @YuraZavadenko Před 2 měsíci

    how do u use server action in client component. Like with this startTransition thing, i truly don't get it

    • @WebDevCody
      @WebDevCody  Před 2 měsíci

      you need to define the server action in a separate file, and if you do revalidatePath or redirect inside the server action, that's when you need a transition where you call startTransition(() => myAction()). The transition is to help keep any button spinners or loaders in place as your application is trying to refresh the other parts of the app after a redirect or revalidation

  • @tarunm
    @tarunm Před 9 dny

    where is the ActionError coming from in this code

  • @rudraprasadpanigrahy8363
    @rudraprasadpanigrahy8363 Před 2 měsíci

    Hey cody, make a one shot video of a complete project in next & also websocket ( if possible). But make sure without any 3rd party library like convex, firebase etc..

    •  Před 2 měsíci

      Something like how do you start a new project, how to set it up, what would you use, etc. Thanks Cody

  • @Louisle88
    @Louisle88 Před 2 měsíci

    Have you ever encountered issues when using useAction to create a form with a file schema?

    • @WebDevCody
      @WebDevCody  Před 2 měsíci

      what do you mean by file schema? like uploading a file to the server action?

    • @Louisle88
      @Louisle88 Před 2 měsíci

      @@WebDevCody I think having issues by Zod : z.instanceof(File)

  • @parkerrex
    @parkerrex Před 2 měsíci

    What theme is this? And the gutter colors ?

    • @parkerrex
      @parkerrex Před 2 měsíci

      shades of purple // indent rainbow

    • @WebDevCody
      @WebDevCody  Před 2 měsíci

      Bearded theme stained blue

  • @durmoth7027
    @durmoth7027 Před 18 dny

    next-safe-action vs zsa? what to use?

    • @WebDevCody
      @WebDevCody  Před 18 dny

      I use zsa because it supports parsing outputs, but next-safe-actions is also good

  • @Schisek
    @Schisek Před 2 měsíci

    Really nice library. But luckily I never really switched to using server actions and stayed with tRPC for all client component stuff. It essentially has the features this library offers built in. Also I prefer handling loading states, error states and all the good stuff using tankstack query (which is used by tRPC). Server actions are cool if you only have like 1-2 forms, other than that I still recommend tRPC

    • @northerncoder
      @northerncoder Před 2 měsíci

      This was what I was wondering. I’ve already understand react-query.. why would I throw that away to learn server actions?

  • @kamleshpaul414
    @kamleshpaul414 Před 2 měsíci

    how you will pass files in safe action

    • @WebDevCody
      @WebDevCody  Před 2 měsíci +1

      I’ll be trying to figure that out soon

  • @lovrozagar3729
    @lovrozagar3729 Před 2 měsíci

    This seems similar to TRPC but for server actions, cool.

    • @alaskandonut
      @alaskandonut Před 14 dny

      Aren’t server actions already a kind of RPC? They’re functions that get triggered remotely.

  • @brunocascio
    @brunocascio Před 2 měsíci +1

    sounds they're taking inspiration on Remix. Good!

    • @anton9410
      @anton9410 Před 2 měsíci

      ohh really, can you explain why exactly since i havent dealt with remix

  • @ElvisMorales
    @ElvisMorales Před 2 měsíci

    What's inside your "@/lib/session"?

    • @WebDevCody
      @WebDevCody  Před 2 měsíci +1

      Just wraps next auths get server session

  • @babayaga6172
    @babayaga6172 Před 2 měsíci

    Hi sir
    I saw rate limiting code in your application ca u give us examples of free rate limiter
    Just like express-rate-limiter
    In express js
    It will be very helpful for us
    Thanks 😊

    • @WebDevCody
      @WebDevCody  Před 2 měsíci

      I published a video today on it

  • @kirillvoloshin2065
    @kirillvoloshin2065 Před 2 měsíci +1

    jeez, frontend is complicated (and I am a frontend dev)

  • @gkiokan
    @gkiokan Před 2 měsíci

    Why is this so complicated in react/next? This could be done way simpler. I am the only one thinking so? Not working on react, but like the Content. But this makes me love vue even more when seeing such "simple" things blows up so much code.
    Wouldn't that be handled though middleware group, limiter and cors already?

    • @WebDevCody
      @WebDevCody  Před 2 měsíci

      I'm not sure what makes this complicated? it's just a function which runs validation using a schema. it's no different from adding a middleware which runs validation against the form post data.

  • @tsykin
    @tsykin Před 2 měsíci

    Would you consider this as necessary in production? How could I protect my server actions without this package?

    • @WebDevCody
      @WebDevCody  Před 2 měsíci +1

      You’d at least want to parse the inputs if parsing is necessary. For example if your server action takes a number for an argument, technically someone could send a string, so you should check that (typescript won’t check it for you at runtime)

    • @tsykin
      @tsykin Před 2 měsíci

      @@WebDevCody Thanks for explanation! I will definately check that out

    • @ValipPowa
      @ValipPowa Před 2 měsíci

      @@WebDevCody wouldn't zod be checking that FOR you? isn't zod checking on the server? when the actions are on the server?

    • @WebDevCody
      @WebDevCody  Před 2 měsíci

      @@ValipPowa yes, zod checks it for you, which is why I’m using this library to have zod check for me

  • @yarrichar
    @yarrichar Před 2 měsíci

    Are you still using upstash for your rate limiting?

    • @WebDevCody
      @WebDevCody  Před 2 měsíci +1

      Right now it’s just in memory because I host on a vps.

    • @iken_ar
      @iken_ar Před 2 měsíci +1

      ​@@WebDevCody can you make a video about it,
      most of us using vps/dedicated server rn 😶
      thank you!!

    • @WebDevCody
      @WebDevCody  Před 2 měsíci +1

      @@iken_ar sure

  • @JS_Jordan
    @JS_Jordan Před 2 měsíci

    i gave up on server actions, and nextjs as a whole. dev experience seriously sucks when the project grows in size. I'm finding a better and more performant experience with vite, hono + bun and tanstack router

  • @codernerd7076
    @codernerd7076 Před 2 měsíci

    why not just make a post api route'!

  • @SheeceGardazi
    @SheeceGardazi Před 2 měsíci +1

    lol this is full circle ... add server code into front end and then step by step realise why having api server was actullly a good idea

    • @Fuzbo_
      @Fuzbo_ Před 2 měsíci

      Yeah the more I’m seeing additional steps outside of the simple example for server actions, I’m wondering what (if any) benefit there is over something like tRPC.

  • @stephenisienyi7726
    @stephenisienyi7726 Před 2 měsíci

    OMG Sheesh Why?

  • @coltzi
    @coltzi Před 2 měsíci

    how about you create a safe api endpoint and add cors so you don't have to overcomplicate some useless bs? like this is a joke

  •  Před 2 měsíci

    2

    •  Před 2 měsíci

      Latam moment when this video doesn't load up 😵‍💫

  • @Kats0unam1
    @Kats0unam1 Před 2 měsíci +29

    A library to fix a problem inherent to nextjs. And this is why I hate the state of FE development

    • @DesiMatrixXD
      @DesiMatrixXD Před 2 měsíci

      Not just frontend development, this is the problem with entire JS ecosystem.

    • @WebDevCody
      @WebDevCody  Před 2 měsíci +14

      How is that a problem specifically with nextjs? If you made a rest api in express you still need to validate your user inputs

    • @DanteMishima
      @DanteMishima Před 2 měsíci

      This is a nextjs problem.... The rest of us in FE don't have these problems

    • @WebDevCody
      @WebDevCody  Před 2 měsíci +13

      @@DanteMishima but server actions are backend. It sounds like y’all think server actions are front end related features

    • @RedVelocityTV
      @RedVelocityTV Před 2 měsíci

      You're clueless man