Navigation überspringen
"Navigation feels slow in Next.js"
0:00 / 0:25

"Navigation feels slow in Next.js"

Alex Sidorenko

@asidorenko_35.232 Follower

Auf X besuchen
1.557 LikesHerunterladenOriginalbeitrag

270.314 Aufrufe

"Navigation feels slow in Next.js" Try cacheComponents 👇

51 Kommentare

Kommentare aus dem Originalbeitrag auf X (Twitter)

  • Profilbild von Alex Sidorenko

    @asidorenko_

    My previous suggestion was to use loading.tsx, but with cacheComponents enabled, the actual part of your page outside of Suspense boundaries acts like loading.tsx (static, prefetched) I'm not sure if you need loading.tsx with cacheComponents at all

    49 Likes

  • Profilbild von Muhammad Azamuddin

    @azamuddin91

    Why another trick? Should it be default without developer thinking about yet another trick?

    28 Likes

  • Profilbild von Muhammad Azamuddin

    @azamuddin91

    Hmmm, I assume there might be gotchas since they don’t want to implement thisas default right away. Perhaps they’ve learnt from the default cache change in around v13 to v14 then revert in v15 What nextjs has become, don’t get me wrong, I still use Nextjs to this date but

    1 Like

  • Profilbild von Vlad Sazonau

    @vladsazonau

    imo this is how it should've worked from the beginning with server components 😌

    21 Likes

  • Profilbild von Alex Sidorenko

    @asidorenko_

    @vlad_sazon Yep, implicitly static-by-default was not the best strategy for the app router. But I'd imagine it was tough to predict this for such a novel model as RSC Whoever paves the road for new technology pays the R&D price

    9 Likes

  • Profilbild von Vlad Sazonau

    @vladsazonau

    Yeah, make sense 🙏

    1 Like

  • Profilbild von ghazi

    @muizahg

    Why not make it fast by default?

    6 Likes

  • Profilbild von Léo Chéron

    @mrgnou

    It doesn't work with dynamic routes so far :/

    5 Likes

  • Profilbild von Kevin Möchel

    @kevin_moechel

    The video is kinda misleading. I can achieve the exact same in Next 15. That's just RSC. The point of the cache is that on subsequent navigations there's no loading state. This wasn't shown in the video

    4 Likes

  • Profilbild von Alex Sidorenko

    @asidorenko_

    It was shown in the video. That's why you don't have lag during navigation on a dynamic page. You can only achieve this in Next 15 with PPR enabled. PPR is now part of cachedComponents model But the main point is that it's impossible to create a blocking route (it errors)

  • Profilbild von Kevin Möchel

    @kevin_moechel

    Everything displayed in your video is easily done in Next 15, except the error when not using Suspense. The actual difference is that the Shell of the page is now served by the Vercel CDN which isn't the case in Next 15.

  • Profilbild von Alex Sidorenko

    @asidorenko_

    "except" and "the actual difference" from your response is exactly the point of the video

  • Profilbild von ian

    @iandavidandrino

    It felt slow locally, until I upgraded to nextjs 16 and upgraded to stable react-compiler 🤯 Now it navigates before I even blink

    3 Likes

  • Profilbild von Matt Teixeira

    @matt_teeixeira

    This only for Next 16?

    3 Likes

  • Profilbild von Alex Sidorenko

    @asidorenko_

    @Matt_TeixeiraBR Yep

    3 Likes

  • Profilbild von Petsoni

    @petsonii

    damn this is something new for me gonna try it out, thank you 🙌🏼

    2 Likes

  • Profilbild von CodeHagen

    @CodeHagen

    Need to try, great one ✨

    2 Likes

  • Profilbild von Lukas

    @quick007YT

    how does this actually improve performance? does it just give a warning when you forgot to use suspense or does it do more under the hood?

    2 Likes

  • Profilbild von Alex Sidorenko

    @asidorenko_

    It pre-generates everything outside Suspense as a static shell during the build time. This shell is prefetched by Links, so navigation is always fast. This was called partial pre-rendering before. Now it's a part of the cacheComponents model.

    5 Likes

  • Profilbild von Lukas

    @quick007YT

    makes sense! I'm familiar with PPR so hopefully cache components will fit into that mental model.

    1 Like