惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
罗磊的独立博客
The GitHub Blog
The GitHub Blog
V
V2EX
Last Week in AI
Last Week in AI
博客园 - 聂微东
MyScale Blog
MyScale Blog
美团技术团队
L
LangChain Blog
博客园 - Franky
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
S
SegmentFault 最新的问题
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Stack Overflow Blog
Stack Overflow Blog
量子位
小众软件
小众软件
宝玉的分享
宝玉的分享
J
Java Code Geeks
Google DeepMind News
Google DeepMind News
D
Docker
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

The Astro Blog

Astro 6.4 Astro 6.3 Starlight 0.39 Astro 6.2 What's new in Astro - April 2026 What's new in Astro - March 2026 Astro 6.1 CloudCannon Joins Astro as an Official CMS Partner Astro 6.0 What's new in Astro - February 2026 What's new in Astro - January 2026 Astro 5.17 Supporting the future of Astro The Astro Technology Company joins Cloudflare Astro 6 Beta What's new in Astro - December 2025 What's new in Astro - November 2025 Astro 5.16 Stainless Sponsors Astro, Launches Astro-Powered Docs Platform What's new in Astro - October 2025 Astro 5.15 Spirit of Astro: meet the winning designs What's new in Astro - September 2025 Astro 5.14 Cloudflare Donates $150,000 to Support Astro's Open Source Mission Webflow Donates $150,000 to Support Astro's Open Source Mission Mux: Our Official Video Partner Unleashing creativity: How CodeTV built a video streaming platform with Astro and Mux | Astro What's new in Astro - August 2025 Astro 5.13
Astro 2.9: View Transitions (experimental)
Matthew Phillips · 2023-07-20 · via The Astro Blog

Astro 2.9 is out and features experimental support for view transitions, as well as redirects configuration and improved script bundling.

  • View Transitions (experimental)
  • Redirects
  • Hoisted script optimization

If you already have Astro installed, you can upgrade it to 2.9 by running the upgrade command in your project (using your package manager of choice):

npm install astro@latest

pnpm upgrade astro --latest

yarn upgrade astro --latest

While you’re at it, upgrade any @astrojs/* integrations and adapters you have installed, too!

View Transitions (experimental)

Watch Ben Holmes explain the new View Transitions feature.

Astro now supports view transitions through the new <ViewTransitions /> component and the transition:animate directive. Enjoy the smoother transitions that previously required client-side routing, without sacrificing the simplicity of an MPA.

Enable support for view transitions in Astro 2.9 by adding the experimental flag to your config:

import { defineConfig } from 'astro/config';

export default defineConfig({

experimental: {

viewTransitions: true,

},

});

<ViewTransitions />

This is a component which acts as the router for transitions between pages. Add it to the <head> section of each individual page where transitions should occur in the client as you navigate away to another page, instead of causing a full page browser refresh.

To enable support throughout your entire app (SPA mode), add the component in some common layout or component that targets the <head> of every page.

CommonHead.astro

---

import { ViewTransitions } from 'astro:transitions';

---

<meta charset="utf-8" />

<title>{Astro.props.title}</title>

<ViewTransitions />

With only this change, your app will now route completely in-client. You can then add transitions to individual elements using the transition:animate directive.

Animations

Add transition:animate to any element to use Astro’s built-in animations.

<header transition:animate="slide"></header>

In the above, Astro’s slide animation will cause the <header> element to slide in from the left, and then slide out to the right when you navigate away from the page.

You can also customize these animations using any CSS animation properties, for example, by specifying a duration:

---

import { slide } from 'astro:transition';

---

<header transition:animate={slide({ duration: 200 })}></header>

Continue learning

Check out the client-side routing docs to learn more.

Redirects

The redirects configuration option is no longer experimental! If you were previously using experimental redirects, remove the following experimental flag:

import { defineConfig } from 'astro/config';

export default defineConfig({

experimental: {

redirects: true,

}

});

If you have been waiting for stabilization before using redirects, wait no longer! You can now safely use redirects in your project. Check out the docs on redirects to learn how to use this built-in feature.

In your configuration, add a map of old and new paths to redirect from and to:

import { defineConfig } from 'astro/config';

export default defineConfig({

redirects: {

'/old-page': '/new-page'

}

});

Hoisted script optimization

Astro’s static analysis to determine which <script> tags to bundle together just got a little smarter!

Astro creates bundles that optimize script usage between pages and place them in the head of the document so that they are downloaded as early as possible. One limitation to Astro’s existing approach has been that you could not dynamically use hoisted scripts. When using libraries that re-exported components, each page received the same, all-inclusive bundle whether or not every script was needed on that page.

Now, Astro has improved the static analysis to take into account the actual imports used.

For example, Astro would previously bundle the <script>s from both the <Tab> and <Accordion> components for the following library that re-exports multiple components:

@matthewp/my-astro-lib

export { default as Tabs } from './Tabs.astro';

export { default as Accordion } from './Accordion.astro';

Now, when an Astro page only uses a single component, Astro will send only the necessary script to the page. A page that only imports the <Accordion> component will not receive any <Tab> component’s scripts:

---

import { Accordion } from '@matthewp/my-astro-lib';

---

You should now see more efficient performance with Astro supporting this common library re-export pattern.

Thanks to Ottomated, a community contributor for working on this new feature.

More

Additional bug fixes and integration features are included in this release. Check out the release notes to learn more.