Is Tanstack Query needed when using Next Route Handlers?

Basically what it says. To my understanding a Route Handler is basically a custom built endpoint that receives a Request and returns a Response. Standard REST-ful stuff really. With that in mind, if I'm fetching data on the client, would something like Tanstack Query still be relevant / provided any significant value? I know the Route Handlers already include caching and revalidation, as does TQ, but I'm not sure if TQ provides anything further that makes it worth including. Given the versatile nature of TQ and the sheer number of features, I imagine so, but wanted to check they weren't already covered by Next.
Routing: Route Handlers | Next.js
Create custom request handlers for a given route using the Web's Request and Response APIs.
N
Neto18d ago
Next Route and Tanstack Query are different things NextRoute creates api endpoints for you TanstackQuery handles async state + caching + deduping and more on client side you can use TSQuery to call api routes, but outside of that, not that much difference
B
bythewayitsjosh18d ago
That's kind of my question. Is wrapping calls to my Route Handlers in TQ queries kind of pointless, given that the Route Handlers already have caching, revalidation etc. built in (or opt-in), or is there enough additional value in the TQ queries to make it worth it?
N
Neto18d ago
TQ in general handles all kinds of async state TSQ caching is good enough APIRoutes caching is a shitshow that isnt worth unless you know what you are doing, caching api responses is quite bad because of stale data
B
bythewayitsjosh18d ago
Presuming I have Route Handlers (which I think are App Router versions of API Routes), I should probably wrap them in TQ then?
N
Neto18d ago
it's a good thing react async handling is awful
B
bythewayitsjosh18d ago
Alright, makes sense. Thanks for the help.
Want results from more Discord servers?
Add your server
More Posts
t3 env doesn't seem to work with docker compose buildI'm working to validate my application before pushing it to my CI/CD pipeline. I keep getting faileNextAuth - Email Provider Breaking Google Provider!Howdy, Some users of my app (app.getriver.io) started reporting not being able to log in to our appVSCode Import Autocomplete Purgatory (Relative, absolute, and barrel paths)I hope I'm missing some easy setting, otherwise this UI seems pretty terrible. Why does the autocompThe In App vs NextAuth problemIf you open the app link from a mobile app (like discord/telegram) and it opens in the in-app browseTypeErrorinitialTree is not iterable in Modern React Tutorial vidThe images map correctly until I try clicking on one, so I think the error may be misleading me. I T3 Roadmap? What would you recommend?I recently landed an internship, and they use the T3 Stack. I already had experience with JS, React,are there any better logs for nextJS that are in Englishjust spent 30min playing around with this and trying to work out the problem all I did was copy and Should I report a bug to a federal(-ish) university without hopes of a bug bounty?I live in nigeria, I attend national open university of nigeria. I recently found out a bug which alFork bombHi, i saw the new video from theo about the AI interview, and on the video he said to the AI to exeCommunication with server and client <nextjs>i have a webhook which calls nextjs api, can that api call do something which triggers an action onReact Native Data Loader libraryDoes anyone know of any good data loader libraries that will prevent waterfalls in React Native? I kNext.js as a client API choiceHaving watched all theo's videos regarding next and APIs (mainly tRPC and server actions), i got theShould I start my own blog, or use an existing platform?So I already have a few articles out on dev.to ( https://dev.to/noblica ) , and a few older ones on Hi guys, I'm peter. I'm starting a new project with all the t3 start recommendEverything ok, I'm the creation process, I'm using supabase as a db provider, but OKTA as a AUTH proUTApi deleteFilesHi, I'm creating an e-commerce admin panel and I have made a function to delete the images you've upRSA_PKCS1_PADDING is no longer supported for private decryption### Summary I am using the native Node crypto module to decrypt data using the `pkcs1` padding scheTutotial - What settings to chooseDoes anyone know what database he is using in this video? Because I want to do it step by step perfeBest resources / learning material?Hi all, I have been developing in HTML and CSS for some time, but looking to move more into JavaScrHELP ME w/ SIMPLE CSS/FLEXBOX(please ty, istg im losing my mind over something so simple) GOAL: I want to apply flex-grow to theShould I switch jobs?I’ve been a software engineer at a large automotive company for 5 years and my base salary is about