Course contentsShow
← Web Development
Lesson 1798 of 2,98233. Static Site Generation and JamstackFree lesson

Fallback Behavior for New Pages

Handling requests for pages that don't exist yet using fallback modes: blocking, true, or false strategies.

Fallback Behavior for New Pages

You'll learn: How to control what happens when a user requests a dynamically-generated static page that hasn't been built yet.

When using Incremental Static Regeneration, you can generate static pages on-demand for routes you didn't pre-build. But what should users see while that first page is being generated? This is where fallback strategies come in.

The Three Fallback Modes

fallback: false
The strictest option. If a page wasn't built at build time, users get a 404. Use this when you know exactly which pages exist and won't add more without rebuilding.

fallback: true
Returns a fallback "loading" version of the page immediately while the real page generates in the background. The first visitor sees a loading state, then the fully-rendered page once ready. Subsequent visitors get the cached version instantly. This keeps your build fast but requires handling the loading state in your UI.

fallback: 'blocking'
The user waits (their request "blocks") until the page fully generates server-side. No loading state needed in your code—the first visitor just experiences a slower load. Once generated, it's cached like any other static page.

Choosing Your Strategy

Think of it like a restaurant:

  • false: "Menu is fixed; we only serve what's listed"
  • true: "We'll start cooking your custom order and bring you breadsticks while you wait"
  • 'blocking': "Wait at the counter while we prepare your custom order, then take it to your table"

Use true for the best user experience when you can handle loading states. Use 'blocking' for simpler code when occasional slow first-loads are acceptable. Use false when your content set is truly static.

Key Takeaway: Fallback strategies let you balance build performance, user experience, and code complexity when generating pages on-demand—choose based on whether you can show loading states and how critical first-visit speed is.