Fallback Strategies
You'll learn how to handle requests for pages that weren't pre-generated at build time.
What Are Fallback Strategies?
When using Static Site Generation with dynamic routes, you can't always predict every possible path users might visit. For example, a blog might have thousands of posts—pre-generating all of them at build time could be impractical. Fallback strategies determine what happens when someone requests a page that doesn't exist yet.
The Three Fallback Options
fallback: false
Returns a 404 page for any path not returned by getStaticPaths. This is the strictest option—only pre-generated pages will work. Use this when you know exactly which pages exist and want to reject everything else.
Think of it like a guest list at an exclusive event: if your name isn't on the list, you can't get in.
fallback: true
Shows fallback content immediately (like a loading skeleton), then generates the page in the background. The first visitor waits for generation, but subsequent visitors get the cached version. Your component receives a "fallback" state you must handle.
Like ordering a custom sandwich: the first customer waits while it's made, then it's added to the menu for everyone else.
fallback: 'blocking'
Blocks the request until the page is fully generated server-side, then serves it. No fallback UI needed in your component, but the first visitor experiences a delay. Similar to on-demand SSR.
Like waiting at a restaurant for your food to be cooked—you don't see anything until it's ready.
Choosing the Right Strategy
Use false for small, fixed sets of pages. Use true for better perceived performance with many pages. Use 'blocking' when you can't show partial content or need simpler component logic.
Key Takeaway: Fallback strategies let you balance build time, user experience, and SEO by controlling how ungenerated pages are handled—blocking, failing, or showing placeholders.