mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Based on: - https://github.com/vercel/next.js/pull/88834 - https://github.com/vercel/next.js/pull/88989 - https://github.com/vercel/next.js/pull/88998 --- Adds optimistic routing, enabling the client to predict route structure for URLs that haven't been prefetched yet. When navigating to a URL like /blog/post-2, if we've previously learned the pattern from /blog/post-1, we can predict the route structure without waiting for a server response. The client learns route patterns from server responses and builds a trie indexed by URL parts. When a cache miss occurs, we check if the URL matches a known pattern. If so, we create a synthetic cache entry from the template, allowing immediate rendering of loading boundaries. Static siblings (like /blog/featured alongside /blog/[slug]) are tracked to avoid incorrect predictions — we only predict dynamic routes when we're confident no static sibling matches.
20 lines
582 B
TypeScript
20 lines
582 B
TypeScript
import Link from 'next/link'
|
|
|
|
// This is a static sibling to /blog/[slug]. Route prediction should NOT
|
|
// apply to this route - it should be resolved via a tree prefetch, not
|
|
// by matching the dynamic [slug] pattern.
|
|
export default function FeaturedPage() {
|
|
return (
|
|
<div id="featured-page">
|
|
<h1 id="featured-title">Featured Blog Post</h1>
|
|
<p id="featured-description">
|
|
This is a static route that exists alongside the dynamic /blog/[slug]
|
|
route.
|
|
</p>
|
|
<Link href="/" id="back-link">
|
|
Back to home
|
|
</Link>
|
|
</div>
|
|
)
|
|
}
|