#astro 2.8.5 to 3.0 upgrade

4 messages · Page 1 of 1 (latest)

naive cobalt
#

is it safe to upgrade from astro 2.8.5 to 3.0 without breaking my app

strong caveBOT
#

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:

  1. Astro.cookies.get(key): In Astro v2.x, Astro.cookies.get(key) would always return an AstroCookie object, even if the cookie did not exist. Astro v3.0 returns undefined for Astro.cookies.get(key) if the cookie does not exist. If you're checking for the existence of the Astro.cookie object before using Astro.cookies.get(key), this change will not break your code. You can safely remove any code that uses has() to check if the value of Astro.cookies is undefined (source (https://docs.astro.build/en/guides/upgrade-to/v3/)).

  2. 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/)).

  3. Images: astro:assets is no longer behind an experimental flag in Astro v3.0. <Image /> is now a built-in component and the previous @astrojs/image integration has been removed. If you had previously enabled the experimental flag for astro: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/)).

  4. 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 new astro/compiler-runtime export has been added for compiler-specific runtime code (source (https://docs.astro.build/en/guides/upgrade-to/v3/)).

#
  1. 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), .flatMap and .flat should now be used to ensure that you are returning a flat array (source (https://docs.astro.build/en/guides/upgrade-to/v3/)).

  2. 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/)).

  3. Astro CLI: Astro v3.0 removes the CLI from the entrypoint, and exports a new set of experimental JavaScript APIs, including dev(), build(), preview(), and sync() (source (https://docs.astro.build/en/guides/upgrade-to/v3/)).

  4. 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/)).

Before upgrading, it's recommended to thoroughly review the v3.0 Upgrade Guide (https://docs.astro.build/en/guides/upgrade-to/v3/) for full details and individual upgrade guidance for each change.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: