Astro Actions (First Look!)

Sdílet
Vložit
  • čas přidán 9. 05. 2024
  • Join the early preview for my course! learnastro.dev
    Astro (server) Actions help you write type-safe backend functions you can call from anywhere. Here's a first look at this new experimental feature!
    🔗 Key Links 🔗
    - Github: github.com/coding-in-public/a...
    ---------------------------------------
    🔗 Additional Links 🔗
    - docs.astro.build/en/reference...
    - github.com/withastro/roadmap/...
    ---------------------------------------
    📹 Related Videos 📹
    - Astro DB: czcams.com/video/yq1uD3pjhM/video.html
    ---------------------------------------
    🎨 VSCode Theming
    - Font: Cascadia Code: github.com/microsoft/cascadia...
    - Theme: marketplace.visualstudio.com/...
    - Icons: marketplace.visualstudio.com/...
    ---------------------------------------
    🌐 Connect With Me 🌐
    - Website: codinginpublic.dev
    - Blog: chrispennington.blog
    - Twitter: / cpenned
    - Patreon: / coding_in_public
    - Buy Me a Coffee: www.buymeacoffee.com/chrispen...
  • Jak na to + styl

Komentáře • 22

  • @bholmesdev
    @bholmesdev Před 18 dny +12

    Fantastic demo! Glad this simplified your code so much. Made a note that the "failed to validate" throw message could include the error messages for debugging. Also, console ninja is SO COOL

    • @CodinginPublic
      @CodinginPublic  Před 18 dny +2

      Thanks for the great tool! I know there's been so much into the crafting of the experience. Excited to see how it continues to develop! And totally agree about console ninja :)

  • @JamesQQuick
    @JamesQQuick Před 15 dny +1

    What a great overview. Thanks so much for this!

  • @jamesdim
    @jamesdim Před 18 dny +3

    Thanks for covering these new features!

    • @CodinginPublic
      @CodinginPublic  Před 18 dny +1

      Yeah, just had a couple of hours to play with it yesterday, but seems really cool!

    • @jamesdim
      @jamesdim Před 18 dny +1

      @@CodinginPublic Definitely! I hope it goes stable soon!

    • @jjaimealeman
      @jjaimealeman Před 18 dny +1

      ​@@jamesdimgiven the speed of the Astro Dev Team - I wouldn't be surprised if it got stable very very soon!!! 😎👍

  • @user-qr1ny5de4r
    @user-qr1ny5de4r Před 11 dny +1

    Thanks for video! But I still have one question: how to use Astro global object in server actions? For example, action for register new user: I want to set cookie (Astro.cookies.set(...)) and redirect user to profile page (Astro.redirect('/profile')), when action adds a new record to DB. How can I do that? 🤔

    • @CodinginPublic
      @CodinginPublic  Před 11 dny +1

      If I understand it correctly, it’s just creating a POST endpoint for you. So you should be able to update your db in the function and then set cookies and redirect all from that action file? I can play around with this today if I think about it.

  • @danielgillett370
    @danielgillett370 Před 17 dny

    Excellent videos! Keep doing what you're doing. I'm a big fan! I'm on your course as well. It's very good. thank you.
    If you don't mind; Do you think Astro could be used as a production unit to spit out static sites.

  • @WillDelish
    @WillDelish Před 17 dny

    Here is the comment pointing out in the last name error message, ye put “first name” 🤓
    Very cool demo! Astro is growing so fast in features, I can’t keep up.

  • @user-bn5eb9um4x
    @user-bn5eb9um4x Před 18 dny +1

    Wonder if this can return multiple error messages after submit a large form?

  • @404-not-found-service

    wwoooww

    • @CodinginPublic
      @CodinginPublic  Před 9 dny +1

      Pretty cool, right!?

    • @404-not-found-service
      @404-not-found-service Před 9 dny

      @@CodinginPublic It's great, I'll leave sub and so on, I like Astro and I'm learning it, there is very interesting content on your channel about it so I'll be here more often, I hope to see more new things from Astro, greetings and much success!

  • @user-bn5eb9um4x
    @user-bn5eb9um4x Před 18 dny +1

    Can I don't use Z?

    • @CodinginPublic
      @CodinginPublic  Před 18 dny

      I think you need to, but that's also kind of the core experience? So if you don't want to use zod to validate, I'd just use something else?

    • @bholmesdev
      @bholmesdev Před 18 dny +1

      You can! If you omit the “input” option, you get the plan FormData object to do whatever you want. But as Chris mentioned, you won’t get that clean isInputError utility for error messages. It’ll be more to do yourself

    • @user-bn5eb9um4x
      @user-bn5eb9um4x Před 16 dny

      @@bholmesdev Ah, thanks for your work on this. For now, I'm still relying on vanilla JavaScript for all forms.