#astro 2.8.5 to 3.0 upgrade
4 messages · Page 1 of 1 (latest)
Hi @naive cobalt. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Upgrading from Astro 2.x to Astro 3.0 may introduce breaking changes to your project, depending on the features you're using. Here are some key changes you should be aware of:
-
Astro.cookies.get(key): In Astro v2.x,
Astro.cookies.get(key)would always return anAstroCookieobject, even if the cookie did not exist. Astro v3.0 returnsundefinedforAstro.cookies.get(key)if the cookie does not exist. If you're checking for the existence of theAstro.cookieobject before usingAstro.cookies.get(key), this change will not break your code. You can safely remove any code that useshas()to check if the value ofAstro.cookiesisundefined(source (https://docs.astro.build/en/guides/upgrade-to/v3/)). -
View Transitions: View transitions are no longer behind an experimental flag in Astro v3.0. If you had enabled this experimental flag in Astro 2.x, there may be some breaking changes. You will need to update your project for Astro v3.0 which now allows view transitions by default (source (https://docs.astro.build/en/guides/view-transitions/)).
-
Images:
astro:assetsis no longer behind an experimental flag in Astro v3.0.<Image />is now a built-in component and the previous@astrojs/imageintegration has been removed. If you had previously enabled the experimental flag forastro:assets, you will need to update your project for Astro v3.0 which now includes assets features by default (source (https://docs.astro.build/en/guides/images/)). -
Internal Astro API entry point export paths: Astro v3.0 removes the two entry points in favor of the existing
astro/runtime/*entrypoint. Additionally, a newastro/compiler-runtimeexport has been added for compiler-specific runtime code (source (https://docs.astro.build/en/guides/upgrade-to/v3/)).
-
getStaticPaths(): Astro v3.0 removes automatic flattening of
getStaticPaths()’s result. If you’re returning an array of arrays instead of an array of objects (as is expected),.flatMapand.flatshould now be used to ensure that you are returning a flat array (source (https://docs.astro.build/en/guides/upgrade-to/v3/)). -
CSS variables: Astro v3.0 removes the kebab-case transform for these camelCase CSS variable names, and only the original camelCase CSS variable is rendered (source (https://docs.astro.build/en/guides/upgrade-to/v3/)).
-
Astro CLI: Astro v3.0 removes the CLI from the entrypoint, and exports a new set of experimental JavaScript APIs, including
dev(),build(),preview(), andsync()(source (https://docs.astro.build/en/guides/upgrade-to/v3/)). -
Web APIs in server code: Astro v3.0 removes these partial shims entirely. Web APIs are no longer available in server-rendered code (source (https://docs.astro.build/en/guides/upgrade-to/v3/)).