Skip navigation
Route Handlers vs Server Actions for data fetching
0:00 / 0:20

Route Handlers vs Server Actions for data fetching

Alex Sidorenko

@asidorenko_35K followers

Visit on X
664 likesDownloadOriginal post

250,089 views

Route Handlers vs Server Actions for data fetching

9 Comments

Comments from the original post on X (Twitter)

  • Barzi Ahmed's profile picture

    @barziahmed

    I didn't understand at all. The post lacks context and details. Is video complimenting Server Actions or the opposite?

    18 likes

  • Alex Sidorenko's profile picture

    @asidorenko_

    Server actions are not great for fetching data from client components as they execute sequentially. The good default is to fetch data in server components when possible and pass it to the client components when needed. When it's impossible/doesn't make sense to fetch in server component (select autocomplete, AI streaming, etc...) it's better to use good old route handlers. Server actions are designed for mutations

    31 likes

  • Barzi Ahmed's profile picture

    @barziahmed

    It's just getting very complicated. @trpcio and @jullerino often say you might not need tRPC if you're using Server Actions, and now Next.js team here say it's bad and etc. It's API! It's not a joke. Please settle urselves and tell us what to choose without mights and maybes.

    8 likes

  • Fitim Bytyqi's profile picture

    @fitimbyttyqi

    Finally, someone making a video about it 🙌 That’s what pushed me to use TRPC because creating route handlers is too much work for me!

    7 likes

  • Yash Suryawanshi's profile picture

    @Yash_9699

    Route Handlers are more flexible for complex scenarios, while Server Actions are simpler and better for straightforward data fetching tasks.

    2 likes

  • Barzi Ahmed's profile picture

    @barziahmed

    @t3dotgg ?? You said trpc is optional and etcetera!

    2 likes

  • Umair's profile picture

    @buildwithumair

    This is more clear

    1 like

  • Kamlesh Paul's profile picture

    @Kamlesh_Paul26

    we can use server component to fetch data and suspense to show loading ui

    1 like

  • Apu's profile picture

    @mentalsegfault

    I kinda wonder why they didn't go full trpc style and just use them for everything..

    1 like