The Ultimate API Showdown: Server Actions, tRPC, GraphQL, and REST Compared!

preview_player
Показать описание
We compare server actions to tRPC, GraphQL and REST to figure out which one is the right one for your application.

👉 VS Code theme and font? Night Wolf [black] and Operator Mono
👉 Terminal Theme and font? oh-my-posh with powerlevel10k_rainbow and SpaceMono NF

00:00 Introduction
00:30 The contenders
02:28 The comparison
09:44 Recommendations
10:35 Finishing up
Рекомендации по теме
Комментарии
Автор

I tried 3 times to get comfortable with GraphQL and I just gave up in the end. The query language may look simple but it becomes this behemoth of code, get comfortable with scrolling. Plus having to define the mutation & query for each is a pain and I just gave up. To clarify Jack's comment on GraphQL letting anything through, thats not exactly true, as behind the scene, your query is run and if its not expecting an query param, it wont process...

Kayotesden
Автор

I always stick to rest, all those years and still that relevant

maximotejedapozo
Автор

Thanks Jack! These days, decisions are getting even tougher. Add tanstack query / table to the mix, and everything compounds further (i.e. where to use client side, where to use server side granularly). Oh the horror. I gave up on graphql, and trpc due to the lack of ease of use. Server actions FTW!

VincentFulco
Автор

Haha. One of my favorite thumbnails yet. 🤣

drewbird
Автор

Even when I use next/svelte, I create my API endpoints then if need be I use server actions in forms etc... But those actions just contact the API. For me it is just a nice thing to have for the front. I like svelte more because backend fetch on your own api does not actually trigger a network request it makes a function call

RachidBoudjelida
Автор

I think it's also worth mentioning, there's still at least one thing that REST APIs are good at: Building APIs that third-party developers can integrate with.

As long as you have a REST API any developer outside your team or company will be able to integrate with your infrastructure. With REST APIs, all they will need is an HTTP client and some documentation.

Flash
Автор

REST also works without JS..., that's the whole point of stuff like htmx and go, but this can be achieved with regular html....
a form is designed to make a post request when submitted to an endpoint, that's why you see a lot of "preventDefault" when using a library, because most of the time you want to do JS stuff before fetching.

TheIpicon
Автор

You can certainly do form requests with rest it is just a matter of how you encode it

breakablec
Автор

graphql queries should be two arrows up, because you literally can build what you want in the request itself.. unlike REST where this filtering logic you gotta do yourself

aleksd
Автор

Hi sir, totally out of context question, may I please know if Micro frontend and module federation is compatible with next 14

vishwasrv
Автор

type safety for rest is very easy to achieve just use schema validators like zod and you can use them on both ends

YouTubePL
Автор

Thank you Jack Herrington! Is there a way to consume tRPC endpoints outside of our next js application in side another application like we consume APIs? If someone wants to consume them in an mobile application.

muhammadameen
Автор

REST is the most well-known and commun, all tutorials start with REST. % of usage and popularity could be good criteria too.

dacam
Автор

tRPC 11 is in the works, and I'm working on some transport layer features. Could you offer any specific feedback on improving Ease of Use, mutations, or queries? Also, I really am scratching my head about the type safety category... what would earn 3 green arrows? 😂

Alec.Vision
Автор

Great content as always. But for me, the complexity of the app to build is a key factor in deciding which method to use. Personally, I don't believe in Server Actions for enterprise-grade applications. The code base is spaghetti code with no seperation of concerns. Same goes for TRPC, which is a little bit nicer but still lacks flexibility for modeling complex business domain interactions.

issamwahbi
Автор

Could not just do a rest request with a form post and then progressively enhance if you have JS to fetch (giving rest an up arrow in "works without JS") ?

croopnick
Автор

is form action the only way to use server function in server component?

planesrift
Автор

does making an api request to the backend REST API inside server action make the mutation slow...??, I mean what do you think about that...??

libenhailu
Автор

HI JACK, I want to build a web using Next.js 14, and a mobile application using Flutter, what is your recommendation to use?

khalidtubail
Автор

I was just thinking about you. Hope all is well.

ts