Why I Use Fetch (And Not tRPC / SWR)

preview_player
Показать описание

I know tRPC/SWR are the hottest tools right now to do data fetching on the client side, but I don't use any of those frameworks. In this video I talk about why I like to use plain old vanilla javascript with the fetch function for all of my API calls.

Рекомендации по теме
Комментарии
Автор

The SWR-logo at 0:07 belongs to the "Südwestrundfunk", which is a german public broadcasting corporation. I doubt that the SWR you are referring to has an official logo since it's just a caching mechanism ^^

heinzvonfritz
Автор

The swr logo you are using is actually from Germany's public South West Radio station (Südwest Rundfunk). 😅

j.m.manhard
Автор

Haha completely sums up what I face personally. LESSER LIBRARIES, LESSER ABSTRACTIONS

sohhamm
Автор

Agree with your point about less library, less dependent, but man using fetch only without types support is kinda out of industry standard, you can do it for yourselves but I am doubtful that your teammate will agree with you, in production, we value stability the most.

UPD
Автор

In general you want to not rely on frameworks as well unopinionated approaches are one of the best things to have for versatility and customized solutions without the headache of opionated stacks relied upon many packages. That said for DX and applications being built for ease, I use TRPC with NextJS in their current stable state, and only ever switch to upgrading with newer versions when stable so I don't run into the whole cutting edge issue.

Preferred personal and bigger projects I most likely won't be using something like TRPC.

kodekorp
Автор

You know what i have been toying with... my backend and frontend are in a monorepo using turbo repo. I was thinking about exporting typed fetch functions for my endpoints that the frontend can import. Like trpc but your own version using fetch api. So your server you would export an object that you can import and use on your frontend that would work like this: api.user.update({}) and all that does is call a fetch function that points to the right api endpoint on your server and is typed so you know what params to pass in and what gets returned.

I think this is what ts-rest does but it adds a little more complexity then what im suggesting.

greggsworld
Автор

Great video.

Unrelated but is that a split unit AC in the background?

uwemisrael
Автор

This is why Angular is so nice, there’s a lot less decision fatigue. My first framework was React, but at work I had to learn Angular for some client, and it’s so nice to have everything provided to the developer out of the box. And it’s honestly not that hard to learn, but I can see why beginners choose not to use it.

tootyrnt
Автор

Also Nextjs 13 was a flop of a release, it got me to switch to Svelte. Trpc doesnt do file uploads :/ Deal breaker for me. ts-rest is a newer trpc that is just a typed fetch api.

greggsworld
Автор

I dont think its thats big a deal to just wait and use an older version for a bit longer

kontheboomer
Автор

you justified why you wouldn't use trpc, how about react query? it provides better fetching already i dont see any reason why not use it lol

oubracode
Автор

I'm just a beginner at web dev but I: liked the control from fetch but obviously it is more work, didn't like swr very much and loved rtk query. If I was to use only fetch I would wind up with my own mini library, thats kind of cool.

skptiks
Автор

t3 stack now has app router support, so you can use tRPC again! but good video :D

andreas.
Автор

Damn, Fetch is already "plain old"!? 😅

CoinOpeBoy
Автор

I thought there was some serious technical reason 🤦🏻‍♂️ Kinda click baitey…

Spectraevil
Автор

What is your opinion about software engineer market? I have two years experience like software developer junior, I'm studying software engineering, How can I get another job?

derror
Автор

so you're saying you don't want to be productive writing code.
small application is fine with just using fetch, but something bigger, you're gonna waste a lot of time

namesarefools
Автор

I regret using `TRPC`, it is not possible or difficult to expose your API's to others. I ended up having a `Internal` and `Public` routers in my app with slightly different implementation. In my view TRPC is too niche for large applications.

DanielNistrean
Автор

This is so misleading. That argument doesn’t stand for trpc, i dont wanna spend time inefficiently writing zod validators, controllers, services, routes manually and then use some openapi typegen tool. I need my api at one place, much like microservices, trpc router enables that.
As far as crud apps are concerned, trpc is phenomenal, this is how rest endpoints are supposed to be

amansagar