Skip to content

vercel-solutions/cache-comp-fallback-test

Repository files navigation

ISR + Suspense Fallback Scenarios

These demos illustrate the behavior of suspense fallbacks in multiple scenarios with some unexpected outcomes.

tl:dr

Compare the behavior of these posts. After loading each page, refresh and observe the suspense fallbacks:

Also note that the presence of 2 suspense boundaries allows instant navigation to the posts, where we'd have expected typical blocking ISR behavior for non-prerendered routes.

The general set up is as follows:

Exhibit A & B

  • layout.tsx in /[lang] route
    • uses generateStaticParams with [{lang: "en"}]
    • top-level navigation
  • 2 child routes /demo1 and /demo2, each with their own layout.tsx
    • layouts have left-nav for child routes
    • each has a post listing page
    • each has two child routes for post detail /dynamic/[postId] and /static/[postId]
      • each uses generateStaticParams with [{postId: "1"}]

Exhibit A

  • /[lang]/layout.tsx top-level nav wrapped w/ suspense

/demo1

  • left nav is not wrapped w/ suspense

/demo2 <-- unexpected behavior

  • left nav is wrapped w/ suspense

Exhibit B

  • /[lang]/layout.tsx top-level nav not wrapped w/ suspense

/demo1

  • left nav is not wrapped w/ suspense

/demo2

  • left nav is wrapped /w suspense

Summary

Exhibit Demo Post Type Suspense Areas Behavior Notes
A 1 Dynamic Posts root nav, post content expected
A 1 Static Posts root nav, post content expected with blocked nav :/
A 2 Dynamic Posts root nav, left nav, post content unexpected
A 2 Static Posts root nav, left nav, post content unexpected
B 1 Dynamic Posts post content expected
B 1 Static Posts post content expected with blocked nav :/
B 2 Dynamic Posts left nav, post content expected
B 2 Static Posts left nav, post content expected with blocked nav :/