Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

Route Handlers vs Server Actions for data fetching

250,089 Aufrufe • vor 1 Jahr •via X (Twitter)

9 Kommentare

Profilbild von Barzi Ahmed
Barzi Ahmedvor 1 Jahr

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

Profilbild von Alex Sidorenko
Alex Sidorenkovor 1 Jahr

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

Profilbild von Barzi Ahmed
Barzi Ahmedvor 1 Jahr

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.

Profilbild von Fitim Bytyqi
Fitim Bytyqivor 1 Jahr

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!

Profilbild von Yash Suryawanshi
Yash Suryawanshivor 1 Jahr

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

Profilbild von Barzi Ahmed
Barzi Ahmedvor 1 Jahr

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

Profilbild von Umair
Umairvor 1 Jahr

This is more clear

Profilbild von Kamlesh Paul
Kamlesh Paulvor 1 Jahr

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

Profilbild von Apu
Apuvor 1 Jahr

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

Ähnliche Videos