正在加载视频...

视频加载失败

Route Handlers vs Server Actions for data fetching

250,089 次观看 • 1 年前 •via X (Twitter)

9 条评论

Barzi Ahmed 的头像
Barzi Ahmed1 年前

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

Alex Sidorenko 的头像
Alex Sidorenko1 年前

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

Barzi Ahmed 的头像
Barzi Ahmed1 年前

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.

Fitim Bytyqi 的头像
Fitim Bytyqi1 年前

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!

Yash Suryawanshi 的头像
Yash Suryawanshi1 年前

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

Barzi Ahmed 的头像
Barzi Ahmed1 年前

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

Umair 的头像
Umair1 年前

This is more clear

Kamlesh Paul 的头像
Kamlesh Paul1 年前

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

Apu 的头像
Apu1 年前

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

相关视频