Tanstack Start vs NextJS - Server Functions Battle

Поділитися
Вставка
  • Опубліковано 15 січ 2025

КОМЕНТАРІ • 88

  • @rijkvanwel
    @rijkvanwel 2 місяці тому +68

    I see Tanstack, I press like

  • @marwen_dev
    @marwen_dev 2 місяці тому +73

    tanner is a genius 🤯, tanstack-start is awesome, when it hit stable v1 many devs will move to using it instead of next.js.

    • @ErniePaschall
      @ErniePaschall 2 місяці тому +6

      Indeed, I am starting to look at it now. Thanks Jack!

    • @Hypawolf
      @Hypawolf 2 місяці тому +6

      I am waiting for stable release as well. Been using NextJS for a while and honestly it's getting more of a hassle to do things in it.

    • @armanrozika
      @armanrozika 2 місяці тому +2

      @@Hypawolf the feel i am feeling when switch from react-router to tanstack-router, life is soooo much much easier

    • @KaranSethia24
      @KaranSethia24 2 місяці тому +1

      isnt this exactly what people say when a new js framework is launched, I remember people said the same thing about remix svelte qwik etc

    • @DrsHWolfenstein
      @DrsHWolfenstein Місяць тому

      ​@@KaranSethia24Everything gets bloated over time. Next.js started out lean and fast, then obesity roared its ugly head.

  • @aibulat1871
    @aibulat1871 2 місяці тому +6

    Returning WebStream from Server Functions -- definitely a great feature!

  • @bits-bytes-and-beyond
    @bits-bytes-and-beyond 2 місяці тому +6

    Can’t wait to use it. Hopefully beta and v0 will come soon enough. Great video, as usual ❤

  • @AbhiShake-pl3cf
    @AbhiShake-pl3cf 2 місяці тому +20

    I agree with what tanner said. The directive that nextjs went for is too magical. How do we pass headers? How do we alter how its sent? I didnt think it would be useful due to my bias towards vercel but it is deffo useful

    • @PraiseYeezus
      @PraiseYeezus 2 місяці тому +3

      'use client' is bad enough, why would I want to control caching through a string? I can only imagine the headaches that will come from self hosting where Next overwrites cache headers...this is the same issue that makes Laravel annoying

    • @AbhiShake-pl3cf
      @AbhiShake-pl3cf 2 місяці тому +1

      @@PraiseYeezus more trouble for opennext people

    • @dzigizord6567
      @dzigizord6567 2 місяці тому

      @@PraiseYeezus "use tanstackstart" is the best directive

  • @nro337
    @nro337 18 днів тому

    super helpful video for understanding our options in 2025! Thanks for a great video!

  • @carlosricardoziegler2650
    @carlosricardoziegler2650 2 місяці тому +1

    Nice content !!!!! What about the state of request ? I mean we can use suspense to show loading, we can handle error and show some user feedback's, in this case we dont need more trpc ? More performant ?

  • @FuzzyAnkles
    @FuzzyAnkles 2 місяці тому +3

    great content as always! 🔥

  • @abdulmustapha532
    @abdulmustapha532 2 місяці тому +16

    Honestly, these days all I like to build with is Tanstack Router in a mono repo with Hono RPC + OpenAPI Typegen.
    Serve my client on a CDN for free, run my Hono API on a machine.
    Life is just easier this side of the fence.

    • @jherr
      @jherr  2 місяці тому +3

      That's a good SPA setup.

    • @oscarresonable2008
      @oscarresonable2008 Місяць тому

      Hi Abdul. I'm curious how do you set this up. Do you mind if you shared any repo for us to look at? It really interest me to jump out of this. Thank you.

    • @furycorp
      @furycorp Місяць тому

      Check out ts-rest, its what all these wannabe RPC-like things wannabe. And yes I've used Hono RPC too.

  • @Adityacode
    @Adityacode 2 місяці тому +6

    Only god knows, how and where the "use cache" stores the cached values? Is it in memory or is it http caching or what ?

    • @jherr
      @jherr  2 місяці тому +5

      The standard adapter is in memory. But you can override the adapter to put it wherever you want. You just need to implement get/set.

    • @Adityacode
      @Adityacode 2 місяці тому

      @jherr Thanks a lot, I was searching through the docs but didn't find it.

  • @dzigizord6567
    @dzigizord6567 2 місяці тому +2

    tanstack start is such a fresh start and such a logical and intuitive way to add server layer on top of the already amazing router. next is shovelling their way too hard, the way that most of us do not want to be the default, plus next router is crap compared to tanstack

  • @rariber
    @rariber 2 місяці тому +18

    I cant stress enough how much I hate how Nextjs server actions works

  • @BrunoDias-v9g
    @BrunoDias-v9g 2 місяці тому +2

    Does it make any sense to use GraphQL with Tanstack Start? Are there any examples?
    Great video 👍

  • @MattChinander
    @MattChinander 2 місяці тому +1

    A nice change to the TS router/start example would have been to follow the Remix pattern where to fn is called through something like useFetcher and the server fn returns the updated value of the count. Avoids doing another request for the loader

    • @tannerlinsley
      @tannerlinsley 2 місяці тому +1

      This is coming and will be built on the new server function middleware/context primitives we just merged in.

    • @karthM8
      @karthM8 29 днів тому

      ​@@tannerlinsley cant we just call server get function at the end and modify the state to get the latest data instead of going for router.invalidate

  • @mahendrakumar-eu6hw
    @mahendrakumar-eu6hw 2 місяці тому +7

    I will use whatever my organization using whether tanstack or next😂
    If you don't you're fired

    • @jherr
      @jherr  2 місяці тому +4

      That's just generally good advice. Not so much the getting fired part. But the "use what the rest of the company is using" advice is pretty good unless you have an extremely compelling business based case not to.

  • @rand0mtv660
    @rand0mtv660 2 місяці тому +1

    I think I've read on twitter that single request mutation + invalidation will come to Tanstack Start, so in your example there wouldn't be a separate request to re-fetch the loader data. It would all happen in a single request like it happens in Next.js
    All in all, Tanstack Start seems very promising.

    • @jherr
      @jherr  2 місяці тому +1

      That'll be interesting to see.

    • @rand0mtv660
      @rand0mtv660 2 місяці тому

      @jherr hopefully I didn't just read something wrong, but it popped up briefly on my Twitter feed.

    • @jherr
      @jherr  2 місяці тому

      @@rand0mtv660 I wouldn't doubt it. I think the intention is to have all of the functionality of NextJS covered and then some. But currently Start doesn't work with 19. Which means that RSCs are currently not supported. So returning an RSC update payload, which is what Next does in this case, would at least right now, not be possible. Which leaves returning new loader content, but that would need to be an interesting hybrid (maybe multipart encoded) payload since you've got the return of the server function itself as well as the loader content coming back.
      And then there is also the issue of whether or not you are using RSCs when they do become available. Next has the advantage in that case that we don't have a choice, you have to use RSCs, so you can architecturally depend on them. That wouldn't hold true for Start if he supports both RSC and non-RSC cases.
      Woof, this stuff is getting complex.

    • @tannerlinsley
      @tannerlinsley 2 місяці тому

      @@jherr Don't complicate it that much. We have always been able to return json from an api endpoint. The main difference with server functions is that they now have transferrable context on top of the payload/result going/coming across the wire. So it should be trivial without 19 or server components to allow middleware to send/receive additional data (like single-flight mutation payloads/streams) on top of what appears on the surface as a simple server function that mutates or fetches some data.

  • @kim-s1y7v
    @kim-s1y7v 2 місяці тому +2

    what is your vscode color theme?

  • @softgripper
    @softgripper 2 місяці тому

    Hey Jack, punted you a mail re: audio sync. Hopefully it reaches you.
    Thanks again for another great video.

  • @mohammadmousavi6046
    @mohammadmousavi6046 2 місяці тому +2

    Hi Jack, which font do you use for VS Code?

    • @MahmoudAhmed-mf6lb
      @MahmoudAhmed-mf6lb 2 місяці тому +1

      That's Cursor not VS Code

    • @jherr
      @jherr  2 місяці тому

      JetBrains Mono. Specifics are in the description.

  • @abhi.r8
    @abhi.r8 2 місяці тому +2

    I am so confused with all the updates I a newbie in react where should I start please anyone answer me

    • @youarethecssformyhtml
      @youarethecssformyhtml Місяць тому +1

      Just learn React and then NextJS. Everyone used to say React will die when Vue was released, yet it's the most popular technology to build apps. Just ignore these shiny stuff and learn what companies use. NextJS is used by a lot of companies. Web dev is just frustrating.

    • @abhi.r8
      @abhi.r8 Місяць тому

      @youarethecssformyhtml learn from where bro I don't even know react tbh

    • @youarethecssformyhtml
      @youarethecssformyhtml Місяць тому

      ​@@abhi.r8 you can learn from their official website (just google it)

    • @youarethecssformyhtml
      @youarethecssformyhtml Місяць тому

      You can learn it from the official website

  • @dataeaseterlaos4920
    @dataeaseterlaos4920 2 місяці тому +2

    I'm a fan of tanstack 🎉🎉🎉🎉

  • @codernerd7076
    @codernerd7076 2 місяці тому +1

    What happened to this framework when Tanner cannot keep working on it for any reason?!

    • @__-se3tf
      @__-se3tf 2 місяці тому +5

      A community forms while he's still active. Tanner hasn't been the top contributor to TanStack Query for a while now.

  • @jeresalem
    @jeresalem 2 місяці тому +14

    Can't way to move on from Next.js!!!

  • @Ss-zg3yj
    @Ss-zg3yj Місяць тому

    Wait, Next doesn't support streaming in server functions???

  • @ecoded3033
    @ecoded3033 2 місяці тому +2

    Tanstack is the manstack

  • @brian-mcbride
    @brian-mcbride 2 місяці тому +1

    This is looking nice. I really prefer Astro as my main "base" as I can have islands that are not React. React is ok, but it always bothers me the various anti-patterns and, in a large way, lack of innovation compared to Solid, Svelte, etc. SSR is great for Vercel in revenue. They sell servers after all. But I am way more into hybrid or SSG approaches when available.

  • @taunado
    @taunado 2 місяці тому +2

    Tanstack Start vs React Router + Vite?

    • @tannerlinsley
      @tannerlinsley 2 місяці тому +11

      I literally built this out of frustration with RR lol😅

    • @taunado
      @taunado 2 місяці тому +2

      ​@@tannerlinsley :D Thanks, I'm excited to fire it up.

    • @harunalrd
      @harunalrd 2 місяці тому

      ​@@tannerlinsleyayoo im waiting your router because frustation with RR 😂

  • @juanmurga1571
    @juanmurga1571 26 днів тому

    Tanstack router is really powerful. I believe in Start!

  • @monogram6357
    @monogram6357 2 місяці тому +1

    Both of them are cool, I like both and use both of them :|

  • @PaulSebastianM
    @PaulSebastianM Місяць тому

    Funny how Next.JS is still not 100% type safe... and one man solved what hundreds of engineers couldn't. :D
    Whenever I see stringly based APIs I feel a sense of repulsion. :P

  • @aminbeee
    @aminbeee 2 місяці тому +1

    At least Tanstack app makes it easier to debug .. NextJS is too ambiguous

  • @VincentDECAUX
    @VincentDECAUX Місяць тому

    Tanstack start is a copy of Remix. But it's nice, I like this approach really. Just hope people will remind that this server approach should be useful, not to just please frontend developers. Full backend API and full front is still the best stack.

    • @tannerlinsley
      @tannerlinsley Місяць тому +2

      Sure, some similarities, but every framework will inevitably have similarities on good ideas. I happily used Remix for 2 years because I liked *some* of it a lot. But so much is entirely different both in API design and definitely implementation. TanStack Router and Start were architected and written from the ground up to allow for things that the Remix/RR team were unwilling to collaborate on, including much needed features and design upgrades from the community, some of those coming from me (type-safety, state-management, caching, etc).

  • @codefinity
    @codefinity 2 місяці тому

    9:29 If it's just a GET, just co-locate that in as a fetch function with GET instead of making non-mutational things a server action?

  • @fortunatomarcelo1567
    @fortunatomarcelo1567 2 місяці тому +1

    Remix?

    • @taunado
      @taunado 2 місяці тому +2

      is now React Router + Vite

  • @SogMosee
    @SogMosee Місяць тому

    between nextjs, remix, and tanstack start, the only reason i use any of this shit is because i can start the server and the client with a single command for my local project apps. I wont ever use ssr until the day aws supports it as natively and cheaply as they do serverless. Until then, most of these changes from react and the rest have just been useless to me as im only doing spa for real apps.

  • @RedVelocityTV
    @RedVelocityTV Місяць тому

    I still prefer Remix over these two

  • @nikoryu-lungma
    @nikoryu-lungma 2 місяці тому +1

    Oh, this thing again?
    I honestly could not give less f*** than I already did with these things.
    For me, anything that works, I'll take it. Just let me know what the tradeoffs are, so that I can measure them.

    • @youarethecssformyhtml
      @youarethecssformyhtml Місяць тому +1

      Yeah I'm also sick of this field with this endless number of frameworks. I'll just use Next

    • @nikoryu-lungma
      @nikoryu-lungma Місяць тому +1

      @@youarethecssformyhtml
      Agree. Just use whatever the heck that works for you. Nothing else actually matters.
      Corporations argue over these things all the times. No wonder their job postings look like they just smoke 10,000 kilograms of weed

  • @vovasvidinsky1369
    @vovasvidinsky1369 2 місяці тому

    Who can please explain how it diff from just call rest api from FE?
    What benefit from all these server actions if I don’t use SSR?

    • @JeromeMeichelbeck
      @JeromeMeichelbeck 2 місяці тому +1

      Rule of thumb: if you don't see any benefit, you probably don't need it.

  • @youarethecssformyhtml
    @youarethecssformyhtml Місяць тому

    At this point, I'm sick of this field (web dev). I'll just use Next and switch to another field after I get a job.

  • @aibulat1871
    @aibulat1871 2 місяці тому

    const count = await getCount() -- that appears much cleaner compared to separate loader(). It pretty much vanilla js, very easy to understand, and does not require to learn a specific API. Same can be told about `export async function serverFunc()` compared to createSserverFN()

  • @scepta6694
    @scepta6694 2 місяці тому

    But you wouldn’t/ shouldn’t fetch data with server actions? Hence always POST. Just have the call directly in the server component no ?

  • @PaulSebastianM
    @PaulSebastianM Місяць тому

    Directives are like decorators: one of the worst design patterns to ever exist!

  • @inversebrah
    @inversebrah 2 місяці тому +1

    boost

  • @gyros9162
    @gyros9162 2 місяці тому +1

    And here we are coding counter with making requests to the server

    • @jherr
      @jherr  2 місяці тому +6

      It's just an example.

    • @tamaniphiri
      @tamaniphiri 2 місяці тому

      Don't be hard on yourself 😂

  • @2gbeh
    @2gbeh 2 місяці тому +1

    Eww

  • @Shoharnaaze
    @Shoharnaaze Місяць тому +1

    Again a new lib/framework?? Pfff 🤢