Astro
Astro Prefetch for Faster Navigation
Written by Noel
Published:
21 min read
Topics researched with AI assistance; reviewed and edited by Noel before publishing.

Explore this topic
More Astro guides, glossary entries, and practical workflows live on the topic hub.
Astro prefetch is Astro’s way of loading internal pages before a visitor clicks them, so navigation feels faster and more responsive. In practical terms, it reduces the waiting time between intent and page change, which matters on content sites, marketing pages, and product flows where every extra second can interrupt momentum.
The key idea is simple: do the work before the click, but only when there is a good signal that the click is likely. That is why Astro gives you multiple strategies instead of a single always-on behavior.
Key takeaways
- Prefetching helps most when the next page is likely to be visited, not when every link is equally important.
- The default hover strategy is a good starting point because it waits for user intent.
- Aggressive prefetching can waste bandwidth and compete with more important page resources.
- You can tune behavior per link or globally, which makes it easier to match real navigation patterns.
- Prefetching improves perceived speed, but it does not replace good page architecture or lightweight pages.
What is it?
Astro prefetch is an opt-in navigation optimization that fetches linked pages in advance. When a visitor hovers over, focuses, taps, scrolls near, or otherwise signals interest in a link, Astro can begin loading the target page in the background so the next navigation feels closer to instant.
That matters because users rarely experience performance as a lab metric. They experience it as friction: a pause after clicking a menu item, a delay after choosing a product page, or a brief stall when moving from one article to another. Prefetching reduces that stall by shifting some of the network work earlier in the interaction.
A concrete example: imagine a merchant site with a homepage, collection pages, and a few high-intent product detail pages. If a visitor hovers over a featured product link and then clicks it, the page may already be partially loaded by the time the click happens. The result is not magic, but it often feels much smoother than a cold navigation.
Astro prefetch is also selective by design. It applies to internal links, not external sites, which keeps the feature focused on your own navigation paths. That makes it a better fit for multi-page applications where the next page is predictable and worth preparing in advance.
In practice, the feature is best understood as a probability tool. It does not guarantee that the next page will be used, but it tries to spend network effort only when the odds are good. That is why it is useful on sites with clear pathways: a homepage that points to a few service pages, a docs site with a logical reading order, or a store where category pages lead naturally into product detail pages. If the site’s navigation is random or exploratory, the value drops quickly.
A useful mental model is to compare it with a reservation system. Instead of waiting until the visitor is already at the door, Astro starts preparing the room when the visitor shows signs of coming. That preparation can make the handoff feel seamless, but only if the reservation is made for the right room. If you reserve too many rooms, the system becomes inefficient; if you reserve the wrong ones, the benefit disappears.
Astro prefetch also fits into the broader idea of “perceived performance.” A page can still take time to render, but if the next page is already waiting when the user asks for it, the experience feels much more immediate. That distinction matters for teams because it changes the optimization target. You are not only trying to make the browser faster in absolute terms; you are trying to remove the visible pause at the moment the visitor decides to move.
Why it matters — business and technical impact
From a business perspective, faster navigation reduces the small moments of hesitation that can break a browsing session. If a visitor is exploring a service page, a portfolio, or a product catalog, every delayed page change creates an opportunity for distraction. Prefetching helps preserve flow, especially in journeys where users move through several pages before converting.
For merchants, that can matter in category browsing, editorial landing pages, and product comparison flows. A visitor who can move from one page to another without waiting is more likely to continue exploring. That does not guarantee conversion, but it removes a common source of friction from the path.
Technically, Astro prefetch is useful because it gives you control over when and how resources are prepared. You are not forced into a blanket behavior. Instead, you can choose whether the site should react on hover, tap, viewport entry, or page load, and you can override that choice for individual links when the context demands it.
The tradeoff is bandwidth and browser work. Prefetching too much can compete with the current page, especially on slower devices or connections. That is why the feature is valuable only when it is applied with restraint. The goal is not to preload everything; the goal is to make likely navigation feel faster without making the current page heavier than it needs to be.
There is also an operational benefit for teams. Because prefetching is configurable, developers can align it with analytics, content priorities, and device behavior instead of guessing. If the data shows that visitors usually move from a category page to a specific product page, that path can be optimized. If another link is visible but rarely used, it can remain untouched. That selective approach keeps the site responsive without turning every page into a background download hub.
A second technical benefit is predictability. When a team knows which interactions trigger prefetching, it becomes easier to reason about network behavior during QA and performance reviews. That is especially helpful on sites that already use image optimization, partial hydration, or other performance features. Prefetching then becomes one part of a broader strategy rather than an isolated trick.
It also helps teams avoid a common performance trap: optimizing the wrong layer. A site can spend weeks shaving milliseconds from rendering while the user still waits after every click. Prefetching addresses that specific gap between intent and navigation. In other words, it improves the moment the user feels most sensitive to delay, which is often more valuable than a small improvement somewhere earlier in the page lifecycle.
How it works — explain the mechanism step by step
Astro prefetch works by adding a prefetch script to your site and then using link-level signals to decide when to fetch target pages. You enable the feature in configuration, and then mark links or configure defaults so Astro knows which navigations should be prepared ahead of time.
The default interaction is hover-based. That means the browser starts prefetching when a user hovers over or focuses a link. This is a useful baseline because it reflects intent without being too eager. If a user merely scrolls past a link or glances at it, nothing happens. If they pause on it, the site can begin loading the destination.
Astro also supports other strategies. tap waits until just before a click, which is useful when hover is not a reliable signal, such as on touch-first devices. viewport starts when a link enters the viewport, which can work well for long lists or article pages where the next likely click is visible on screen. load prefetches all links after the page loads, which is the most aggressive option and usually the one that needs the most caution.
There is also a programmatic path through the astro:prefetch module. That matters when the navigation is not a plain anchor tag or when you want to trigger prefetching from a custom interaction, such as a button or a scripted menu. In that case, you can call prefetch() from client-side code and use the same browser-aware safeguards.
A useful way to think about the mechanism is in layers:
- The site decides whether prefetching is enabled.
- A link or interaction signals that a page may be needed soon.
- Astro fetches the target page in the background.
- The browser keeps that work ready for the actual navigation.
- If the user never clicks, the benefit may be lost, but the cost is limited by the strategy you chose.
That is why strategy selection matters as much as the feature itself. The same prefetch system can be gentle or aggressive depending on how you configure it.
Astro also tries to avoid wasting effort in low-value situations. The docs note that prefetching can fall back to a less aggressive behavior on data saver mode or slow connections, which is important because the same interaction that feels great on a fast laptop can feel intrusive on a constrained mobile network. In other words, the mechanism is not just “fetch early”; it is “fetch early when the browser and network conditions make that a sensible tradeoff.”
There is a practical distinction between prefetching and actually navigating. Prefetching prepares the destination, but it does not replace the click or the browser’s normal navigation rules. That means the feature is safest when it is used to reduce delay, not to change user expectations. Visitors should still feel in control of the journey, and the site should still behave like a normal set of links.
Another important detail is that prefetching is not the same as rendering the page in advance. It can reduce the amount of work left at click time, but the browser still has to complete the navigation and paint the destination. That is why the best results come when prefetching is paired with lightweight pages, efficient assets, and a clear route structure. If the destination is expensive to render, prefetching can only do part of the job.
Use cases — where teams actually apply this
One common use case is editorial and content-heavy navigation. If you run a blog, docs site, or knowledge base, readers often move from one article to the next through related links, category links, or in-page navigation. Prefetching can make those next steps feel smoother, especially when the destination pages are lightweight and the links are clearly intentional.
A second use case is marketing and portfolio sites. These sites often have a small set of high-value pages: home, services, case studies, about, contact, and maybe a few landing pages. Prefetching can help the visitor move through that journey without obvious pauses, which keeps attention on the message rather than the loading state. For a portfolio or agency site, that can make the browsing experience feel more polished.
A third use case is product discovery flows on merchant sites. Think of a collection page with filters, featured products, and editorial blocks. If visitors tend to move from a collection to a product page and then to a related product or brand story, prefetching the likely next page can reduce the sense of waiting between decisions. It works best when the site structure already reflects a clear path.
The important decision criterion is predictability. If you can reasonably guess the next click, prefetching is more likely to help. If users jump unpredictably between unrelated pages, a lighter or more selective setup is usually better. That is why the feature is strongest in structured browsing environments and weaker in chaotic navigation patterns.
It is also useful for teams that maintain multiple navigation surfaces. A top nav, a footer, a related-content block, and a card grid do not all deserve the same treatment. The top nav may be a good candidate for hover or tap because it reflects deliberate intent. A dense grid of dozens of cards may be better served by viewport only on the most important items. Thinking in terms of navigation surfaces helps teams avoid the mistake of applying one global rule to every link on the site.
For developers, another use case is reducing the perceived lag in multi-step flows without moving to a full single-page app. A site can remain an MPA and still feel quick if the next page is prepared at the right moment. That is useful for teams that want the simplicity of server-rendered pages but still want a more app-like browsing experience.
A final use case is internal navigation in campaign or seasonal pages. If a landing page has a small number of follow-up destinations, prefetching can keep the journey moving without forcing the visitor to wait after a call to action. That is especially helpful when the page is designed to funnel attention toward one or two next steps rather than many competing choices.
How to implement or apply it — practical guidance
Start by deciding whether you want a global default or a selective rollout. If your site has a small number of important internal links, selective prefetching is often the cleaner choice. If most internal navigation is meaningful and the site is not resource-heavy, a broader default may be acceptable.
A practical implementation path is to enable prefetching in astro.config.mjs, then add data-astro-prefetch to the links that matter most. That gives you control without forcing every link to behave the same way. For example, a homepage hero link, primary navigation items, and a few high-intent related links may deserve prefetching before everything else does.
If you need a different interaction model, choose the strategy that matches the device and the page layout. Hover works well for desktop navigation. Tap is more natural for touch-first behavior. Viewport can help on pages where the next likely click appears in a visible list. Load should be treated carefully because it is the broadest and most expensive option.
A good implementation workflow looks like this:
- Identify the pages that users are most likely to visit next.
- Check whether those pages are light enough to prefetch without crowding the current page.
- Choose a default strategy that matches the dominant device behavior.
- Override individual links where intent is stronger or weaker than the default.
- Test on slow connections and lower-powered devices, not just on a fast desktop.
If you use custom buttons or scripted navigation, the prefetch() API can help. Use it only in client-side code, since it depends on browser APIs. That makes it a useful tool for interactive UI patterns, but not a replacement for thoughtful link design.
One more practical point: if your pages already use Astro’s islands architecture, prefetching should still be evaluated as a navigation optimization, not a component fix. Islands can keep the page light, while prefetching can make the next page arrive sooner. They solve different problems.
A sensible rollout usually starts with one or two high-value paths rather than the entire site. For example, a team might prefetch the primary nav and the most clicked related links for a week, then compare how the site feels on mobile and desktop. If the experience improves without obvious bandwidth cost, they can expand. If not, they can narrow the scope or switch strategies. That incremental approach is safer than enabling everything at once and hoping the browser will sort it out.
When you implement it, keep the content model in mind. A link inside a product card, a link in a sticky header, and a link at the bottom of an article do not carry the same intent. The more the link is tied to a likely next step, the more valuable prefetching becomes. That is why a good implementation is usually editorial as much as it is technical: someone has to decide which paths deserve the extra help.
If you are working with a larger site, it can help to create a simple prefetch policy before you touch code. For example: primary navigation gets hover, high-intent cards get viewport, touch-heavy flows get tap, and everything else stays off unless analytics prove it matters. That policy gives designers, editors, and developers a shared rule set, which makes the feature easier to maintain over time.
Common mistakes and pitfalls
The most common mistake is treating prefetching as a default performance win. It is not. If you prefetch too many pages, you can create unnecessary network activity, especially on mobile devices or on connections where bandwidth is limited. The result may be a busier browser without a noticeable user benefit.
Another mistake is choosing the wrong strategy for the interaction. Hover is not always meaningful on touch devices, and viewport is not always useful when the visible links are low-value or numerous. The strategy should reflect actual behavior, not just what seems technically elegant.
A third pitfall is ignoring page weight. If the destination pages are large, prefetching may pull in more data than the user is likely to need. That can be acceptable for a small number of critical pages, but it becomes risky when applied broadly across a large site.
It is also easy to forget that prefetching only helps internal links. If your navigation depends heavily on external destinations, the feature will not solve that part of the experience. In that case, you may need to improve link placement, reduce friction in the current page, or rethink the journey itself.
Finally, do not assume that prefetching can compensate for poor information architecture. If users cannot predict where a link leads, or if the site’s structure is confusing, loading pages earlier will not fix the underlying problem. The best results come when the site already has clear paths and the feature simply removes the waiting time from those paths.
A related mistake is failing to revisit the setup after content changes. A link that deserves prefetching today may become low-value after a redesign, and a page that was too heavy last quarter may be light enough now. Prefetch rules should be treated as living configuration, not a one-time optimization. If the site’s navigation changes, the prefetch strategy should be reviewed at the same time.
Another pitfall is overestimating how much prefetching can hide slow rendering. If the destination page itself is expensive to render, prefetching may only shift the delay earlier rather than removing it. In that case, the better fix may be to simplify the destination page, reduce client-side work, or improve asset delivery before expanding prefetch coverage.
There is also a subtle UX risk: prefetching can make a site feel jumpy if it is triggered too eagerly. A visitor may move their pointer across several links while browsing, and if the site starts fetching on every brief pass, the browser can end up doing work for pages the user never intended to open. That is why intent thresholds matter. A good setup should feel invisible most of the time, not constantly active.
Best practices and quick checklist
The safest approach is to start small and expand only where the evidence supports it. Prefetch the links that matter most, observe how visitors move through the site, and then decide whether to widen the rollout. That keeps the feature aligned with real behavior rather than assumptions.
A strong prefetch setup usually follows a few principles. First, it respects intent: use hover or tap for most links, and reserve more aggressive strategies for pages where the next click is highly predictable. Second, it protects bandwidth: avoid prefetching everything unless the site is small and the navigation is tightly controlled. Third, it stays maintainable: document which links are prefetched and why, so future edits do not undo the logic.
Use this checklist when you apply it:
- Prefetch only the pages users are likely to visit next.
- Match the strategy to the device and interaction pattern.
- Keep the default conservative unless you have a clear reason not to.
- Test on slow networks and mobile hardware.
- Review whether prefetching is still useful after major navigation changes.
A final best practice is to pair prefetching with good link placement. If the next step is obvious and easy to reach, prefetching can make that step feel seamless. If the next step is buried or ambiguous, the feature will have limited value. In other words, prefetching works best as a finishing layer on top of a well-structured site.
It also helps to think in terms of “high confidence” and “low confidence” links. High-confidence links are the ones users almost always choose next, such as a primary CTA, a top navigation item, or a related article directly tied to the current page. Low-confidence links are the ones that are visible but not strongly tied to the current task. Prefetch the first group first, and only expand into the second group if the data supports it.
A quick operational checklist for teams:
- Confirm the site’s most common next-page paths.
- Decide which links deserve prefetching by default.
- Pick a strategy that matches the dominant device mix.
- Verify that slow connections still behave sensibly.
- Recheck the setup after content, layout, or navigation changes.
If you want a simple rule of thumb, use this: prefetch when the next page is both likely and valuable, avoid it when the next page is uncertain or expensive. That one decision rule prevents most of the common mistakes and keeps the feature focused on the moments where it actually improves the experience.
From practice — illustrative scenario (hypothetical, not a client project)
Illustrative example — not a real client project: imagine a merchant site built in Astro with a homepage, a few collection-style landing pages, and a set of editorial product guides. The site already loads quickly, but visitors still pause between pages because each navigation triggers a fresh request and a visible wait.
A typical merchant might notice that the most common journey starts on the homepage, moves into a featured collection, then into one or two product detail pages, and finally into a contact or checkout-related page. The navigation is predictable, but the site does not yet prepare the next page in advance. The team wants the experience to feel smoother without making every page heavier.
A practical approach would be to enable prefetching selectively. The primary navigation links and the most important collection links could use the default hover strategy, because those are clear intent signals on desktop. On touch-first pages, the team might prefer tap for the links that are most likely to be clicked next. For a long article page with a related-links section, viewport could make sense for the few links that appear near the bottom of the reading flow.
The team would then review the site structure and ask a few questions: Which pages are truly high intent? Which links are visible but rarely used? Which destinations are too heavy to prefetch broadly? That review usually reveals that a small number of pages deserve the optimization, while the rest should stay untouched.
The implementation workflow would likely be incremental. First, the team would enable prefetching in configuration and apply it only to the primary nav. Next, they would add data-astro-prefetch to a handful of related links on the most important pages. After that, they would test the experience on a slow mobile connection and on a desktop browser with a mouse, because the same strategy can feel very different across devices.
If the team saw that hover-based prefetching was helping desktop users but doing little for mobile visitors, they could keep hover for desktop-oriented paths and use tap for touch-heavy pages. If a specific collection page had too many links to prefetch safely, they could narrow the scope to the top two or three items instead of prefetching the whole grid. That kind of adjustment is where the feature becomes practical rather than theoretical.
The team might also create a simple decision rule for future edits: if a link is part of the primary journey, it can be prefetched; if it is exploratory, seasonal, or low-traffic, it stays off by default. That rule makes the setup easier to maintain when new campaigns or pages are added.
In a second pass, the team could compare the behavior of different sections of the site. For example, the homepage might benefit from hover because visitors intentionally explore the main nav, while a long editorial page might benefit more from viewport because readers scroll to the next article suggestion. The point is not to use one strategy everywhere, but to match the strategy to the shape of the journey.
The takeaway is not that prefetching should be everywhere. It is that the feature works best when it follows the user’s natural path. If the site already makes the next step obvious, Astro prefetch can remove the last bit of waiting and make the journey feel more fluid.
Related concepts and further reading
Astro prefetch sits alongside other performance and navigation tools. If you are deciding how far to push it, it helps to understand the surrounding pieces rather than treating it as a standalone trick.
- Astro content collections guide — useful when your prefetched pages are content-heavy and need clean structure.
- Astro islands architecture — helpful for keeping pages light before you optimize navigation.
- Astro Themes — a practical starting point if you want a faster Astro site without building every layout from scratch.
- Astro Prefetch docs — the official reference for strategies, configuration, and API details.
If you are comparing approaches, it can also help to look at view transitions, client-side routing patterns, and general page-weight optimization. Those topics answer adjacent questions: how the page changes visually, how much work the browser must do before navigation, and how much content should be loaded in the first place. Prefetching is strongest when those other pieces are already in good shape.
Explore this topic
More Astro guides, glossary entries, and practical workflows live on the topic hub.
Frequently asked questions
What does astro prefetch do?
Astro prefetch loads a linked page in the background before a visitor clicks it. That can make navigation feel much faster because the browser already has the next page ready or partly ready. It only applies to internal links, so it is meant for movement within your own site rather than external destinations.
Which prefetch strategy should I use by default?
The default hover strategy is usually the safest starting point because it waits for a clear signal of intent. It works well for menus, related content links, and most editorial sites. If your users navigate by tapping quickly or if links appear as they scroll, another strategy may fit better.
Does astro prefetch always improve performance?
No. It improves perceived speed when visitors are likely to follow a link, but it can also waste bandwidth if you prefetch too aggressively. The best setup depends on traffic patterns, page weight, and whether your audience uses slower connections or data saver modes.
Can I prefetch every link on a page?
Astro supports prefetching all links by default, but that is not always the right choice. It can be useful on small, highly navigable sites where most links are likely to be used. On larger pages or content-heavy sites, selective prefetching is usually easier to control.
How does astro prefetch work with view transitions?
Prefetching and view transitions solve different parts of the navigation experience. Prefetching gets the next page data ready earlier, while view transitions smooth the visual swap between pages. Used together, they can make navigation feel more immediate and polished, but each feature should still be tested on real content and real devices.
How do I decide between hover, tap, viewport, and load?
Choose the strategy that matches how people actually discover links on your site. Hover is best when desktop users pause over links before clicking. Tap is better when the interaction is touch-first. Viewport works when visible links in a list are likely to be clicked next. Load is the broadest option and should be reserved for small sites or tightly controlled navigation because it can consume more bandwidth.