2.0.2
Patch Changes
-
#5983
b53e0717bThanks @natemoo-re! - Fixes a dev server edge case where prerender + getStaticPaths would not 404 on an unmatched route -
#5992
60b32d585Thanks @HiDeoo! - FixAstro.url.protocolwhen using the @astrojs/node SSR adapter with HTTPS -
#5971
883e0cc29Thanks @JLarky! - improve error message: change @astrojs/solid to @astrojs/solid-js -
#5970
dabce6b8cThanks @bholmesdev! - Add type guard support to filters ongetCollection() -
#5952
aedf23f85Thanks @wulinsheng123! - Fix custom theme handling for<Code>component -
Updated dependencies [
7abb1e905]:- @astrojs/markdown-remark@2.0.1
2.0.1
Patch Changes
-
#5969
f4c71e5ebThanks @matthewp! - Fix usage of logger in Vercel EdgeThis protects against usage of
processglobal in shimmed environments. -
#5962
46b6e1426Thanks @MoustaphaDev! - Fix Content Collections not loading config file when there are spaces in the folder tree -
#5972
02549b8ceThanks @bluwy! - Correctly detect Node.js version
2.0.0
Note This is a detailed changelog of all changes in Astro v2.
See our upgrade guide for an overview of steps needed to upgrade an existing project.
Major Changes
-
#5687
e2019be6fThanks @bholmesdev! - Give remark and rehype plugins access to user frontmatter via frontmatter injection. This meansdata.astro.frontmatteris now the complete Markdown or MDX document's frontmatter, rather than an empty object.This allows plugin authors to modify existing frontmatter, or compute new properties based on other properties. For example, say you want to compute a full image URL based on an
imageSrcslug in your document frontmatter:export function remarkInjectSocialImagePlugin() { return function (tree, file) { const { frontmatter } = file.data.astro; frontmatter.socialImageSrc = new URL(frontmatter.imageSrc, 'https://my-blog.com/').pathname; }; }
When using Content Collections, you can access this modified frontmatter using the
remarkPluginFrontmatterproperty returned when rendering an entry.Migration instructions
Plugin authors should now check for user frontmatter when applying defaults.
For example, say a remark plugin wants to apply a default
titleif none is present. Add a conditional to check if the property is present, and update if none exists:export function remarkInjectTitlePlugin() { return function (tree, file) { const { frontmatter } = file.data.astro; + if (!frontmatter.title) { frontmatter.title = 'Default title'; + } } }This differs from previous behavior, where a Markdown file's frontmatter would always override frontmatter injected via remark or reype.
-
#5891
05caf445dThanks @bholmesdev! - Remove deprecated Markdown APIs from Astro v0.X. This includesgetHeaders(), the.astroproperty for layouts, and therawContent()andcompiledContent()error messages for MDX. -
#5778
49ab4f231Thanks @bluwy! - Remove proload to load the Astro config. It will now use NodeJS and Vite to load the config only. -
#5728
8fb28648fThanks @natemoo-re! - The previously experimental features--experimental-error-overlayand--experimental-prerender, both added in v1.7.0, are now the default.You'll notice that the error overlay during
astro devhas a refreshed visual design and provides more context for your errors.The
prerenderfeature is now enabled by default when usingoutput: 'server'. To prerender a particular page, addexport const prerender = trueto your frontmatter.Warning Integration authors that previously relied on the exact structure of Astro's v1.0 build output may notice some changes to our output file structure. Please test your integrations to ensure compatability. Users that have configured a custom
vite.build.rollupOptions.output.chunkFileNamesshould ensure that their Astro project is configured as an ESM Node project. Either include"type": "module"in your rootpackage.jsonfile or use the.mjsextension forchunkFileNames. -
#5782
1f92d64eaThanks @Princesseuh! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0 -
#5771
259a539d7Thanks @matthewp! - Removes support for astroFlavoredMarkdownIn 1.0 Astro moved the old Astro Flavored Markdown (also sometimes called Components in Markdown) to a legacy feature. This change removes the
legacy.astroFlavoredMarkdownoption completely.In 2.0 this feature will not be available in Astro at all. We recommend migration to MDX for those were still using this feature in 1.x.
-
#5941
304823811Thanks @bholmesdev! - Content collections: Introduce a newslugfrontmatter field for overriding the generated slug. This replaces the previousslug()collection config option from Astro 1.X and the 2.0 beta.When present in a Markdown or MDX file, this will override the generated slug for that entry.
# src/content/blog/post-1.md --- title: Post 1 + slug: post-1-custom-slug ---
Astro will respect this slug in the generated
slugtype and when using thegetEntryBySlug()utility:--- import { getEntryBySlug } from 'astro:content'; // Retrieve `src/content/blog/post-1.md` by slug with type safety const post = await getEntryBySlug('blog', 'post-1-custom-slug'); ---
Migration
If you relied on the
slug()config option, you will need to move all custom slugs toslugfrontmatter properties in each collection entry.Additionally, Astro no longer allows
slugas a collection schema property. This ensures Astro can manage theslugproperty for type generation and performance. Remove this property from your schema and any relevantslug()configuration:const blog = defineCollection({ schema: z.object({ - slug: z.string().optional(), }), - slug({ defaultSlug, data }) { - return data.slug ?? defaultSlug; - }, }) -
#5753
302e0ef8fThanks @bluwy! - Default preview host tolocalhostinstead of127.0.0.1. This allows the static server and integration preview servers to serve under ipv6. -
#5716
dd56c1941Thanks @bluwy! - Remove MDX Fragment hack. This was used by@astrojs/mdxto access theFragmentcomponent, but isn't required anymore since@astrojs/mdxv0.12.1. -
#5584
9963c6e4d& #5842c4b0cb8bfThanks @wulinsheng123 and @natemoo-re! - Breaking Change: client assets are built to an_astrodirectory in the build output directory. Previously these were built to various locations, includingassets/,chunks/and the root of build output.You can control this location with the new
buildconfiguration option namedassets. -
#5893
be901dc98Thanks @matthewp! - RenamegetEntrytogetEntryBySlugThis change moves
getEntrytogetEntryBySlugand accepts a slug rather than an id.In order to improve support in
[id].astroroutes, particularly in SSR where you do not know what the id of a collection is. UsinggetEntryBySluginstead allows you to map the[id]param in your route to the entry. You can use it like this:--- import { getEntryBySlug } from 'astro:content'; const entry = await getEntryBySlug('docs', Astro.params.id); if (!entry) { return new Response(null, { status: 404, }); } --- <!-- You have an entry! Use it! -->
-
#5685
f6cf92b48Thanks @bluwy! - Upgrade to Vite 4. Please see its migration guide for more information. -
#5724
16c7d0bfdThanks @bluwy! - Remove outdated Vue info log. RemovetoStringsupport forRenderTemplateResult. -
#5684
a9c292026& #576993e633922Thanks @bholmesdev! - Refine Markdown and MDX configuration options for ease-of-use.-
Markdown
-
Replace the
extendDefaultPluginsoption with agfmboolean and asmartypantsboolean. These are enabled by default, and can be disabled to remove GitHub-Flavored Markdown and SmartyPants. -
Ensure GitHub-Flavored Markdown and SmartyPants are applied whether or not custom
remarkPluginsorrehypePluginsare configured. If you want to apply custom plugins and remove Astro's default plugins, manually setgfm: falseandsmartypants: falsein your config.
-
-
Migrate
extendDefaultPluginstogfmandsmartypantsYou may have disabled Astro's built-in plugins (GitHub-Flavored Markdown and Smartypants) with the
extendDefaultPluginsoption. This has now been split into 2 flags to disable each plugin individually:markdown.gfmto disable GitHub-Flavored Markdownmarkdown.smartypantsto disable SmartyPants
// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ markdown: { - extendDefaultPlugins: false, + smartypants: false, + gfm: false, } });Additionally, applying remark and rehype plugins no longer disables
gfmandsmartypants. You will need to opt-out manually by settinggfmandsmartypantstofalse. -
MDX
-
Support all Markdown configuration options (except
drafts) from your MDX integration config. This includessyntaxHighlightingandshikiConfigoptions to further customize the MDX renderer. -
Simplify
extendPluginsto anextendMarkdownConfigoption. MDX options will default to their equivalent in your Markdown config. By settingextendMarkdownConfigto false, you can "eject" to set your own syntax highlighting, plugins, and more.
-
-
Migrate MDX's
extendPluginstoextendMarkdownConfigYou may have used the
extendPluginsoption to manage plugin defaults in MDX. This has been replaced by 3 flags:extendMarkdownConfig(trueby default) to toggle Markdown config inheritance. This replaces theextendPlugins: 'markdown'option.gfm(trueby default) andsmartypants(trueby default) to toggle GitHub-Flavored Markdown and SmartyPants in MDX. This replaces theextendPlugins: 'defaults'option.
-
-
#5717
a3a7fc929Thanks @bluwy! - Removestyle.postcssAstro config. Refactor tailwind integration to configure throughviteinstead. Also disablesautoprefixerin dev. -
#5825
52209ca2aThanks @bholmesdev! - Baseline the experimentalcontentCollectionsflag. You're free to remove this from your astro config!import { defineConfig } from 'astro/config'; export default defineConfig({ - experimental: { contentCollections: true } }) -
#5707
5eba34fccThanks @bluwy! - Remove deprecatedAstroglobal APIs, includingAstro.resolve,Astro.fetchContent, andAstro.canonicalURL.-
Astro.resolveYou can resolve asset paths using
importinstead. For example:--- import 'style.css'; import imageUrl from './image.png'; --- <img src={imageUrl} />
See the v0.25 migration guide for more information.
-
Astro.fetchContentUse
Astro.globinstead to fetch markdown files, or migrate to the Content Collections feature.let allPosts = await Astro.glob('./posts/*.md');
-
Astro.canonicalURLUse
Astro.urlinstead to construct the canonical URL.const canonicalURL = new URL(Astro.url.pathname, Astro.site);
-
-
#5608
899214298Thanks @konojunya! - A trailing slash will not be automatically appended toimport.meta.env.SITE. Instead, it will be the value of thesiteconfig as is. This may affect usages of${import.meta.env.SITE}image.png, which will need to be updated accordingly. -
#5707
5eba34fccThanks @bluwy! - RemovebuildConfigoption parameter from integrationastro:build:starthook in favour of thebuild.configoption in theastro:config:setuphook.export default function myIntegration() { return { name: 'my-integration', hooks: { 'astro:config:setup': ({ updateConfig }) => { updateConfig({ build: { client: '...', server: '...', serverEntry: '...', }, }); }, }, }; }
Minor Changes
-
#5901
a342a486cThanks @bluwy! - The fallback Svelte preprocessor will only be applied if a custompreprocessoption is not passed to thesvelte()integration option, or in thesvelte.config.jsfile.To support IDE autocompletion, or if you're migrating from
@astrojs/sveltev1, you can create asvelte.config.jsfile with:import { vitePreprocess } from '@astrojs/svelte'; export default { preprocess: vitePreprocess(), };
This file will also be generated by
astro add svelteby default. -
#5786
c2180746bThanks @bholmesdev! - Move generated content collection types to a.astrodirectory. This replaces the previously generatedsrc/content/types.generated.d.tsfile.If you're using Git for version control, we recommend ignoring this generated directory by adding
.astroto your .gitignore.Astro will also generate the TypeScript reference path to include
.astrotypes in your project. This will update your project'ssrc/env.d.tsfile, or write one if none exists. -
#5826
840412128Thanks @bholmesdev! - Allow Zod objects, unions, discriminated unions, intersections, and transform results as content collection schemas.Migration
Astro requires a
z.object(...)wrapper on all content collection schemas. Update your content collections config like so:// src/content/config.ts import { z, defineCollection } from 'astro:content'; const blog = defineCollection({ - schema: { + schema: z.object({ ... }) -
#5823
1f49cddf9Thanks @delucis! - Generate content types when runningastro check -
#5832
2303f9514Thanks @HiDeoo! - Add support for serving well-known URIs with the @astrojs/node SSR adapter
Patch Changes
-
#5855
16dc36a87Thanks @natemoo-re! - Remove legacy compiler error handling -
#5822
01f3f463bThanks @natemoo-re! - Fix edge case with bundle generation by emitting a single chunk for pages -
#5803
ae8a012a7Thanks @bluwy! - Upgrade compiler and handle breaking changes -
#5840
cf2de5422Thanks @chenxsan! - Persist CLI flags when restarting the dev server -
#5884
ce5c5dbd4Thanks @MoustaphaDev! - Add a theme toggle button to the error overlay -
#5824
665a2c222Thanks @bholmesdev! - Better handle content type generation failures:- Generate types when content directory is empty
- Log helpful error when running
astro syncwithout a content directory - Avoid swallowing
config.tssyntax errors from Vite
-
#5499
4987d6f44Thanks @bluwy! - Handle custom injected entry files during build -
#5734
55cea0a9dThanks @natemoo-re! - Fixprerenderwhen used withgetStaticPaths -
#5845
e818cc046Thanks @bluwy! - Fix importing client-side components with alias -
#5849
8c100a6feThanks @bluwy! - Handle server restart from Vite plugins -
#5756
116d8835cThanks @matthewp! - Fix for hoisted scripts in project with spaces in the file path -
#5917
7325df412Thanks @natemoo-re! - Fix duplicate CSS in dev mode whenvite.css.devSourcemapis provided -
#5743
2a5786419Thanks @Princesseuh! - Add error location during build for user-generated errors -
#5761
fa8c131f8Thanks @bholmesdev! - Add helpful error message when the MDX integration is missing. -
#5896
64b8082e7Thanks @natemoo-re! - Update@astrojs/compilertov1.0.0 -
#5829
23dc9ea96Thanks @giuseppelt! - FixCode.astroshiki css class replace logic -
#5836
63a6ceb38Thanks @natemoo-re! - Fix route matching when path includes special characters -
#5909
5fd9208d4Thanks @jasikpark! - Update compiler to 1.0.1 -
#5852
3a00ecb3eThanks @rishi-raj-jain! - Respectvite.envPrefixif provided -
#5872
b66d7195cThanks @bluwy! - EnableskipLibCheckby default -
Updated dependencies [
93e633922,e2019be6f,1f92d64ea,12f65a4d5,46ecd5de3,16107b6a1,c55fbcb8e,a9c292026,1f92d64ea,52209ca2a,7572f7402]:- @astrojs/markdown-remark@2.0.0
- @astrojs/telemetry@2.0.0
- @astrojs/webapi@2.0.0
2.0.0-beta.4
See changes in 2.0.0-beta.4
Major Changes
-
#5941
304823811Thanks @bholmesdev! - Content collections: Introduce a newslugfrontmatter field for overriding the generated slug. This replaces the previousslug()collection config option from Astro 1.X and the 2.0 beta.When present in a Markdown or MDX file, this will override the generated slug for that entry.
# src/content/blog/post-1.md --- title: Post 1 + slug: post-1-custom-slug ---
Astro will respect this slug in the generated
slugtype and when using thegetEntryBySlug()utility:--- import { getEntryBySlug } from 'astro:content'; // Retrieve `src/content/blog/post-1.md` by slug with type safety const post = await getEntryBySlug('blog', 'post-1-custom-slug'); ---
Migration
If you relied on the
slug()config option, you will need to move all custom slugs toslugfrontmatter properties in each collection entry.Additionally, Astro no longer allows
slugas a collection schema property. This ensures Astro can manage theslugproperty for type generation and performance. Remove this property from your schema and any relevantslug()configuration:const blog = defineCollection({ schema: z.object({ - slug: z.string().optional(), }), - slug({ defaultSlug, data }) { - return data.slug ?? defaultSlug; - }, })
Patch Changes
-
#5499
4987d6f44Thanks @bluwy! - Handle custom injected entry files during build -
#5917
7325df412Thanks @natemoo-re! - Fix duplicate CSS in dev mode whenvite.css.devSourcemapis provided -
#5909
5fd9208d4Thanks @jasikpark! - Update compiler to 1.0.1 -
Updated dependencies [
46ecd5de3]:- @astrojs/webapi@2.0.0-beta.1
2.0.0-beta.3
See changes in 2.0.0-beta.3
Major Changes
-
#5891
05caf445dThanks @bholmesdev! - Remove deprecated Markdown APIs from Astro v0.X. This includesgetHeaders(), the.astroproperty for layouts, and therawContent()andcompiledContent()error messages for MDX. -
#5893
be901dc98Thanks @matthewp! - Move getEntry to getEntryBySlugThis change moves
getEntrytogetEntryBySlugand accepts a slug rather than an id.In order to improve support in
[id].astroroutes, particularly in SSR where you do not know what the id of a collection is. UsinggetEntryBySluginstead allows you to map the[id]param in your route to the entry. You can use it like this:--- import { getEntryBySlug } from 'astro:content'; const entry = await getEntryBySlug('docs', Astro.params.id); if (!entry) { return new Response(null, { status: 404, }); } --- <!-- You have an entry! Use it! -->
-
#5608
899214298Thanks @konojunya! - A trailing slash will not be automatically appended toimport.meta.env.SITE. Instead, it will be the value of thesiteconfig as is. This may affect usages of${import.meta.env.SITE}image.png, which will need to be updated accordingly.
Minor Changes
-
#5901
a342a486cThanks @bluwy! - The fallback Svelte preprocessor will only be applied if a custompreprocessoption is not passed to thesvelte()integration option, or in thesvelte.config.jsfile.To support IDE autocompletion, or if you're migrating from
@astrojs/sveltev1, you can create asvelte.config.jsfile with:import { vitePreprocess } from '@astrojs/svelte'; export default { preprocess: vitePreprocess(), };
This file will also be generated by
astro add svelteby default.
Patch Changes
-
#5855
16dc36a87Thanks @natemoo-re! - Remove legacy compiler error handling -
#5884
ce5c5dbd4Thanks @MoustaphaDev! - Add a theme toggle button to the error overlay -
#5845
e818cc046Thanks @bluwy! - Fix importing client-side components with alias -
#5849
8c100a6feThanks @bluwy! - Handle server restart from Vite plugins -
#5896
64b8082e7Thanks @natemoo-re! - Update@astrojs/compilertov1.0.0 -
#5852
3a00ecb3eThanks @rishi-raj-jain! - Respectvite.envPrefixif provided -
#5872
b66d7195cThanks @bluwy! - EnableskipLibCheckby default
2.0.0-beta.2
See changes in 2.0.0-beta.2
Major Changes
-
#5782
1f92d64eaThanks @Princesseuh! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0 -
#5753
302e0ef8fThanks @bluwy! - Default preview host tolocalhostinstead of127.0.0.1. This allows the static server and integration preview servers to serve under ipv6. -
#5842
c4b0cb8bfThanks @natemoo-re! - Breaking Change: client assets are built to an_astrodirectory in the build output directory. Previously these were built to various locations, includingassets/,chunks/and the root of build output.You can control this location with the new
buildconfiguration option namedassets. -
#5825
52209ca2aThanks @bholmesdev! - Baseline the experimentalcontentCollectionsflag. You're free to remove this from your astro config!import { defineConfig } from 'astro/config'; export default defineConfig({ - experimental: { contentCollections: true } })
Minor Changes
-
#5786
c2180746bThanks @bholmesdev! - Move generated content collection types to a.astrodirectory. This replaces the previously generatedsrc/content/types.generated.d.tsfile.If you're using Git for version control, we recommend ignoring this generated directory by adding
.astroto your .gitignore.Astro will also generate the TypeScript reference path to include
.astrotypes in your project. This will update your project'ssrc/env.d.tsfile, or write one if none exists. -
#5826
840412128Thanks @bholmesdev! - Allow Zod objects, unions, discriminated unions, intersections, and transform results as content collection schemas.Migration
Astro requires a
z.object(...)wrapper on all content collection schemas. Update your content collections config like so:// src/content/config.ts import { z, defineCollection } from 'astro:content'; const blog = defineCollection({ - schema: { + schema: z.object({ ... }) -
#5823
1f49cddf9Thanks @delucis! - Generate content types when runningastro check -
#5832
2303f9514Thanks @HiDeoo! - Add support for serving well-known URIs with the @astrojs/node SSR adapter
Patch Changes
-
#5822
01f3f463bThanks @natemoo-re! - Fix edge case with bundle generation by emitting a single chunk for pages -
#5803
ae8a012a7Thanks @bluwy! - Upgrade compiler and handle breaking changes -
#5840
cf2de5422Thanks @chenxsan! - Persist CLI flags when restarting the dev server -
#5824
665a2c222Thanks @bholmesdev! - Better handle content type generation failures:- Generate types when content directory is empty
- Log helpful error when running
astro syncwithout a content directory - Avoid swallowing
config.tssyntax errors from Vite
-
#5829
23dc9ea96Thanks @giuseppelt! - FixCode.astroshiki css class replace logic -
#5836
63a6ceb38Thanks @natemoo-re! - Fix route matching when path includes special characters -
Updated dependencies [
1f92d64ea,12f65a4d5,16107b6a1,c55fbcb8e,1f92d64ea,52209ca2a,7572f7402]:- @astrojs/telemetry@2.0.0-beta.0
- @astrojs/markdown-remark@2.0.0-beta.2
- @astrojs/webapi@2.0.0-beta.0
2.0.0-beta.1
See changes in 2.0.0-beta.1
Major Changes
-
#5778
49ab4f231Thanks @bluwy! - Remove proload to load the Astro config. It will now use NodeJS and Vite to load the config only. -
#5771
259a539d7Thanks @matthewp! - Removes support for astroFlavoredMarkdownIn 1.0 Astro moved the old Astro Flavored Markdown (also sometimes called Components in Markdown) to a legacy feature. This change removes the
legacy.astroFlavoredMarkdownoption completely.In 2.0 this feature will not be available in Astro at all. We recommend migration to MDX for those were still using this feature in 1.x.
-
#5717
a3a7fc929Thanks @bluwy! - Removestyle.postcssAstro config. Refactor tailwind integration to configure throughviteinstead. Also disablesautoprefixerin dev.
Minor Changes
-
#5769
93e633922Thanks @bholmesdev! - Introduce asmartypantsflag to opt-out of Astro's default SmartyPants plugin.{ markdown: { smartypants: false, } }
Migration
You may have disabled Astro's built-in plugins (GitHub-Flavored Markdown and Smartypants) with the
extendDefaultPluginsoption. This has now been split into 2 flags to disable each plugin individually:markdown.gfmto disable GitHub-Flavored Markdownmarkdown.smartypantsto disable SmartyPants
// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ markdown: { - extendDefaultPlugins: false, + smartypants: false, + gfm: false, } });
Patch Changes
-
#5734
55cea0a9dThanks @natemoo-re! - Fixprerenderwhen used withgetStaticPaths -
#5756
116d8835cThanks @matthewp! - Fix for hoisted scripts in project with spaces in the file path -
#5743
2a5786419Thanks @Princesseuh! - Add error location during build for user-generated errors -
#5761
fa8c131f8Thanks @bholmesdev! - Add helpful error message when the MDX integration is missing. -
Updated dependencies [
93e633922]:- @astrojs/markdown-remark@2.0.0-beta.1
2.0.0-beta.0
See changes in 2.0.0-beta.0
Major Changes
-
#5687
e2019be6fThanks @bholmesdev! - Give remark and rehype plugins access to user frontmatter via frontmatter injection. This meansdata.astro.frontmatteris now the complete Markdown or MDX document's frontmatter, rather than an empty object.This allows plugin authors to modify existing frontmatter, or compute new properties based on other properties. For example, say you want to compute a full image URL based on an
imageSrcslug in your document frontmatter:export function remarkInjectSocialImagePlugin() { return function (tree, file) { const { frontmatter } = file.data.astro; frontmatter.socialImageSrc = new URL(frontmatter.imageSrc, 'https://my-blog.com/').pathname; }; }
Content Collections - new
remarkPluginFrontmatterpropertyWe have changed inject frontmatter to modify frontmatter in our docs to improve discoverability. This is based on support forum feedback, where "injection" is rarely the term used.
To reflect this, the
injectedFrontmatterproperty has been renamed toremarkPluginFrontmatter. This should clarify this plugin is still separate from thedataexport Content Collections expose today.Migration instructions
Plugin authors should now check for user frontmatter when applying defaults.
For example, say a remark plugin wants to apply a default
titleif none is present. Add a conditional to check if the property is present, and update if none exists:export function remarkInjectTitlePlugin() { return function (tree, file) { const { frontmatter } = file.data.astro; + if (!frontmatter.title) { frontmatter.title = 'Default title'; + } } }This differs from previous behavior, where a Markdown file's frontmatter would always override frontmatter injected via remark or reype.
-
#5728
8fb28648fThanks @natemoo-re! - The previously experimental features--experimental-error-overlayand--experimental-prerender, both added in v1.7.0, are now the default.You'll notice that the error overlay during
astro devhas a refreshed visual design and provides more context for your errors.The
prerenderfeature is now enabled by default when usingoutput: 'server'. To prerender a particular page, addexport const prerender = trueto your frontmatter.Warning Integration authors that previously relied on the exact structure of Astro's v1.0 build output may notice some changes to our output file structure. Please test your integrations to ensure compatability. Users that have configured a custom
vite.build.rollupOptions.output.chunkFileNamesshould ensure that their Astro project is configured as an ESM Node project. Either include"type": "module"in your rootpackage.jsonfile or use the.mjsextension forchunkFileNames. -
#5716
dd56c1941Thanks @bluwy! - Remove MDX Fragment hack. This was used by@astrojs/mdxto access theFragmentcomponent, but isn't require anymore since@astrojs/mdxv0.12.1. -
#5685
f6cf92b48Thanks @bluwy! - Upgrade to Vite 4. Please see its migration guide for more information. -
#5724
16c7d0bfdThanks @bluwy! - Remove outdated Vue info log. RemovetoStringsupport forRenderTemplateResult. -
#5684
a9c292026Thanks @bholmesdev! - Refine Markdown and MDX configuration options for ease-of-use.Markdown
- Remove
remark-smartypantsfrom Astro's default Markdown plugins. - Replace the
extendDefaultPluginsoption with a simplifiedgfmboolean. This is enabled by default, and can be disabled to remove GitHub-Flavored Markdown. - Ensure GitHub-Flavored Markdown is applied whether or not custom
remarkPluginsorrehypePluginsare configured. If you want to apply custom plugins and remove GFM, manually setgfm: falsein your config.
MDX
- Support all Markdown configuration options (except
drafts) from your MDX integration config. This includessyntaxHighlightingandshikiConfigoptions to further customize the MDX renderer. - Simplify
extendDefaultsto anextendMarkdownConfigoption. MDX options will default to their equivalent in your Markdown config. By settingextendMarkdownConfigto false, you can "eject" to set your own syntax highlighting, plugins, and more.
Migration
To preserve your existing Markdown and MDX setup, you may need some configuration changes:
Smartypants manual installation
Smartypants has been removed from Astro's default setup. If you rely on this plugin, install
remark-smartypantsand apply to yourastro.config.*:// astro.config.mjs import { defineConfig } from 'astro/config'; + import smartypants from 'remark-smartypants'; export default defineConfig({ markdown: { + remarkPlugins: [smartypants], } });Migrate
extendDefaultPluginstogfmYou may have disabled Astro's built-in plugins (GitHub-Flavored Markdown and Smartypants) with the
extendDefaultPluginsoption. Since Smartypants has been removed, this has been renamed togfm.// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ markdown: { - extendDefaultPlugins: false, + gfm: false, } });Additionally, applying remark and rehype plugins no longer disables
gfm. You will need to opt-out manually by settinggfmtofalse.Migrate MDX's
extendPluginstoextendMarkdownConfigYou may have used the
extendPluginsoption to manage plugin defaults in MDX. This has been replaced by 2 flags:extendMarkdownConfig(trueby default) to toggle Markdown config inheritance. This replaces theextendPlugins: 'markdown'option.gfm(trueby default) to toggle GitHub-Flavored Markdown in MDX. This replaces theextendPlugins: 'defaults'option.
- Remove
-
#5707
5eba34fccThanks @bluwy! - Remove deprecatedAstroglobal APIs, includingAstro.resolve,Astro.fetchContent, andAstro.canonicalURL.Astro.resolveYou can resolve asset paths using
importinstead. For example:--- import 'style.css'; import imageUrl from './image.png'; --- <img src={imageUrl} />
See the v0.25 migration guide for more information.
Astro.fetchContentUse
Astro.globinstead to fetch markdown files, or migrate to the Content Collections feature.let allPosts = await Astro.glob('./posts/*.md');
Astro.canonicalURLUse
Astro.urlinstead to construct the canonical URL.const canonicalURL = new URL(Astro.url.pathname, Astro.site);
-
#5707
5eba34fccThanks @bluwy! - RemovebuildConfigoption parameter from integrationastro:build:starthook in favour of thebuild.configoption in theastro:config:setuphook.export default function myIntegration() { return { name: 'my-integration', hooks: { 'astro:config:setup': ({ updateConfig }) => { updateConfig({ build: { client: '...', server: '...', serverEntry: '...', }, }); }, }, }; }
Patch Changes
1.9.2
Patch Changes
1.9.1
Patch Changes
1.9.0
Minor Changes
- #5666
bf210f784Thanks @bholmesdev! - Correctly handle spaces and capitalization insrc/content/file names. This introduces github-slugger for slug generation to ensure slugs are usable bygetStaticPaths. Changes:- Resolve spaces and capitalization:
collection/Entry With Spaces.mdbecomescollection/entry-with-spaces. - Truncate
/indexpaths to base URL:collection/index.mdbecomescollection
- Resolve spaces and capitalization:
Patch Changes
-
#5720
fe316be86Thanks @umarov! - Do not add base path to a hoisted script body -
#5706
c2844a79cThanks @bluwy! - Add preact and sitemap integration to config load external list -
#5700
3aa3e00a6Thanks @bholmesdev! - Fiximport.meta.env.DEValways being set totruewhen using Content Collections
1.8.0
Minor Changes
- #5647
d72da5290Thanks @bholmesdev! - Addastro syncCLI command for type generation
Patch Changes
-
#5668
9674cf56cThanks @bholmesdev! - Remove strayconsole.logfrom content collections error message -
#5652
0b5098758Thanks @bluwy! - Use acorn to postprocess Astro globs -
#5648
853081d1cThanks @bholmesdev! - Prevent relative image paths insrc/content/ -
#5678
f8f576829Thanks @bluwy! - Fix code generation quotes handling -
#5635
376f67011Thanks @SegaraRai! - Addserver.headerstyping -
Updated dependencies [
853081d1c,2c65b433b]:- @astrojs/markdown-remark@1.2.0
1.7.2
Patch Changes
-
#5641
62580ed07Thanks @chenxsan! - Fix "Maximum call stack size exceeded" error in vite-plugin-head-propagation -
#5644
d5aff85dbThanks @natemoo-re! - Fix static build regression where chunks would not be generated -
#5639
1ac1ed86eThanks @bluwy! - Fixclient:onlyimports with"importsNotUsedAsValues": "error"tsconfig
1.7.1
Patch Changes
- #5617
33dcaa05bThanks @bholmesdev! - Fix error message when using Content Collections and an out-of-date@astrojs/mdxintegration
1.7.0
Minor Changes
-
#5297
d2960984cThanks @natemoo-re! - Introduces the experimental Prerender API.Note This API is not yet stable and is subject to possible breaking changes!
- Deploy an Astro server without sacrificing the speed or cacheability of static HTML.
- The Prerender API allows you to statically prerender specific
pages/at build time.
Usage
- First, run
astro build --experimental-prerenderor enableexperimental: { prerender: true }in yourastro.config.mjsfile. - Then, include
export const prerender = truein any file in thepages/directory that you wish to prerender.
-
#5495
31ec84797Thanks @Princesseuh! - Add a new error overlay designed by @doodlemarks! This new overlay should be much more informative, clearer, astro-y, and prettier than the previous one. -
#5291
5ec0f6ed5Thanks @bholmesdev! - Introduce Content Collections experimental API- Organize your Markdown and MDX content into easy-to-manage collections.
- Add type safety to your frontmatter with schemas.
- Generate landing pages, static routes, and SSR endpoints from your content using the collection query APIs.
-
#5341
6b156dd3bThanks @alexpdraper! - Allow setting domain when deleting cookies
Patch Changes
- #5615
d85ec7484Thanks @natemoo-re! - Sanitize dynamically rendered tags to strip out any attributes
1.6.15
Patch Changes
-
#5572
b2f0210c4Thanks @matthewp! - Include base in 'page' stage injected scripts -
#5554
02bb0a1ccThanks @natemoo-re! - Update@astrojs/compilerto latest -
#5577
2bd23e454Thanks @jerzakm! - Updated magic-string to 0.27.0
1.6.14
Patch Changes
-
#5545
9082a850eThanks @bluwy! - Exclude astro from Vite optimization -
#5446
4f7f20616Thanks @jyasskin! - Fix redirect() typing to allow all redirection status codes. -
#5511
05915fec0Thanks @matthewp! - Low-level head propagationThis adds low-level head propagation ability within the Astro runtime. This is not really usable within an Astro app at the moment, but provides the APIs necessary for
renderEntryto do head propagation. -
#5553
1aeabe417Thanks @matthewp! - Fix Astro.params not having values when using base in SSR -
#5549
795f00f73Thanks @matthewp! - Use accumulated sort order when order production CSS -
#5539
2c836b9d1Thanks @wulinsheng123! - Error reporting fails on undefined error index -
#5548
8f3f67c96Thanks @ido-pluto! - Removed premature optimization
1.6.13
Patch Changes
-
#5506
f536a34e5Thanks @bluwy! - Dedupe Astro package when resolving -
#5506
f536a34e5Thanks @bluwy! - Refactor Astro compile flow -
#5533
58188e053Thanks @bluwy! - Refactor and remove esbuild dependency -
#5501
3c44033e4Thanks @Princesseuh! - Added a warning in build when trying to hydrate an Astro component
1.6.12
Patch Changes
-
#5484
731e99df8Thanks @Pimm! - Narrow type ofParams, as its values cannot be numbers -
#5480
c13775279Thanks @sapphi-red! - Fix astro preview not working on Windows -
#5497
ca01a71ebThanks @bluwy! - Refactor internal plugins code -
#5460
57888e069Thanks @bluwy! - Fix linked Astro library style HMR -
#5477
5e693c214Thanks @bluwy! - Prevent inlining SCSS partials in dev -
#5498
1a3923da7Thanks @bluwy! - Optimize JSX import source detection
1.6.11
Patch Changes
-
#5433
936c1e411Thanks @wtchnm! - Add missingfetchpriorityattribute to img, link, script and iframe elements -
#5437
4b188132eThanks @bluwy! - Correctly transform third-party JSX files -
#5434
f5ed630bcThanks @matthewp! - Use Vite's resolve to resolve paths for client:only
1.6.10
Patch Changes
-
#5431
1ab505855Thanks @matthewp! - Fix regression with loading .ts in .mjs config -
#5426
ff35b4759Thanks @bluwy! - Fix JSX tagging for anonymous higher-order components default export -
#5430
b22ba1c03Thanks @bluwy! - Fix preview --host in Node.js 18 -
#5417
a9f7ff966Thanks @matthewp! - Prevent dev from crashing when there are errors in template
1.6.9
Patch Changes
-
#5409
9f80a4046Thanks @matthewp! - Fix Code component usage in Vercel -
#5410
3c5cb6948Thanks @impcyber! - Fix: withastro#5400 -
#5412
a278c7ae6Thanks @matthewp! - Restart dev server on package.json changes -
#5377
40226dd14Thanks @matthewp! - Uses vite to load astro.config.ts files
1.6.8
Patch Changes
-
#5375
f9104354bThanks @Princesseuh! - Fix regression causing nested arrays ingetStaticPaths's return value to throw an error -
#5346
f3181b5adThanks @bluwy! - Fix .html.astro file routing in dev -
#5358
9eee0f016Thanks @matthewp! - Properly support trailingSlash: never with a base -
#5345
3ae2a961bThanks @bluwy! - Respect Vite user config for third-party packages config handling -
#5371
bee8c14afThanks @matthewp! - Prefer thebaseconfig rather than site config for creating URLs for links and scripts. -
#5369
e385076efThanks @natemoo-re! - Upgrade@astrojs/compiler, fixes regression withbodyhandling whenheadcontains a Component node
1.6.7
Patch Changes
-
#5353
b3d936ac2Thanks @matthewp! - Updated the CSS naming algorithm to prevent clashes -
#5294
ae41f25e1Thanks @mrienstra! - Consistent Markdown frontmatter typing (MarkdownAstroData["frontmatter"]in particular wasobjectbefore)
1.6.6
Patch Changes
-
#5316
a780f2595Thanks @Princesseuh! - Improved error messages descriptions and hints to be more informative -
#5331
688f8e4bcThanks @matthewp! - Allow dynamic segments in injected routes -
#5330
7e19e8b30Thanks @matthewp! - Prevent jsx throws from hanging server -
#5328
bcd0f8f8cThanks @matthewp! - 404 when not using subpath for items in public in devPreviously if using a base like
base: '/subpath/you could load things from the root, which would break in prod. Now you must include the subpath. -
#5339
03a8f89d5Thanks @natemoo-re! - Upgrade@astrojs/compilerto latest -
#5327
0dcdc6fb1Thanks @Princesseuh! - Update Astro language-server to 0.28.3
1.6.5
Patch Changes
-
#5326
88c1bbe3aThanks @matthewp! - Fix omitted island hydration scripts in slots -
#5301
a79a37cadThanks @bluwy! - Improve environment variable handling performance
1.6.4
Patch Changes
-
#5290
b2b291d29Thanks @matthewp! - Handle base configuration in adaptersThis allows adapters to correctly handle
baseconfiguration. Internally Astro now matches routes when the URL includes thebase.Adapters now also have access to the
removeBasemethod which will remove thebasefrom a pathname. This is useful to look up files for static assets. -
#5292
97e2b6ad7Thanks @MontelAle! - Changes slow astro cli imports to dynamic -
#5293
4af4d8fa0Thanks @matthewp! - Prevent overcaching .astro HMR changes -
#5314
f6add3924Thanks @matthewp! - Fixes regression with config file restarts -
#5298
247eb7411Thanks @wulinsheng123! - have not founded style when srcDir was root
1.6.3
Patch Changes
-
#5273
c7b9b14a1Thanks @matthewp! - Surface astro.config errors to the user -
#5264
0d27c4a2bThanks @VladCuciureanu! - Fixed memleak caused by project dir names containing '.md' or '.mdx' -
#5258
74759cf78Thanks @bluwy! - Allow 200 response for endpoints in build -
#5284
126cd8e83Thanks @herteleo! - Include missingclass:listwithinHTMLAttributestype -
#5236
1cc067052Thanks @bluwy! - Refactor CSS preprocessing handling -
#5198
c77a6cbe3Thanks @matthewp! - HMR - Improved error recoveryThis improves error recovery for HMR. Now when the dev server finds itself in an error state (because a route contained an error), it will recover from that state and refresh the page when the user has corrected the mistake.
1.6.2
Patch Changes
-
#5243
7d678c9edThanks @matthewp! - Upgrade@astrojs/compilerto 0.29.x -
Updated dependencies [
b6a478f37]:- @astrojs/webapi@1.1.1
1.6.1
Patch Changes
-
#5233
7f8987085Thanks @bluwy! - Support rendering@motionone/solidcomponents -
#5238
26ff42905Thanks @MoustaphaDev! - Fix not included file extension inurlmetadata for newly added markdown files -
#5217
8c83359e3Thanks @Princesseuh! - Fix missing types.d.ts in npm package -
#5206
d64d5b9b5Thanks @Princesseuh! - Improve error messages related to CSS and compiler errors -
#5212
a609a8937Thanks @bluwy! - Allow importing public files in SSR
1.6.0
Minor Changes
-
#5147
0bf0758fbThanks @natemoo-re! - Addastro/typesentrypoint. These utilities can be used for common prop type patterns.HTMLAttributesIf you would like to extend valid HTML attributes for a given HTML element, you may use the provided
HTMLAttributestype—it accepts an element name and returns the valid HTML attributes for that element name.import { HTMLAttributes } from 'astro/types'; interface Props extends HTMLAttributes<'a'> { myProp?: string; }
-
#5164
4a8a346caThanks @MoustaphaDev! - Add support for markdown files with the following extensions:.markdown.mdown.mkdn.mkd.mdwn
-
#4917
ddf2f8390Thanks @natemoo-re! - Add support for--baseCLI argument, which will override thebaseset in yourastro.config.mjsfile.astro --site https://astro.build --base /docs
Patch Changes
1.5.3
Patch Changes
-
#5133
1c477dd8dThanks @bluwy! - Update@astrojs/compilerand use the newresolvePathoption. This allows removing much of the runtime code, which should improve rendering performance for Astro and MDX pages. -
#5192
8728ee0b9Thanks @tony-sull! -astro addno longer automatically installs optional peer dependencies
1.5.2
Patch Changes
-
#5119
430e0346cThanks @bluwy! - Usefs.promises.rmto remove node deprecation warning -
#5123
9745009aeThanks @matthewp! - Fixes index page with build.format=file -
#5116
500acb3c1Thanks @matthewp! - Throws when using Response.redirect in SSG mode
1.5.1
Patch Changes
-
#5110
0edfdd325Thanks @bluwy! - Ensure CLI flags override function-style server config -
#5106
ef0c54316Thanks @bluwy! - Support spread parameters for server endpoints -
#5095
ddfbef5acThanks @Princesseuh! - Fixastro addtrying to add lines from extended configurations when adding frameworks -
#5076
6f9a88b31Thanks @Princesseuh! - Fix jsconfig.json aliases not working anymore after 1.5.0 -
#5080
90b715d5cThanks @matthewp! - Fix Astro-in-MDX dashes in slot attr -
#5098
f684e9d36Thanks @jkjustjoshing! - Separate type definitions for built-in HTML elements and custom elements. Helpful when implementing an "as" prop similar to styled-components. -
#5108
ce01225a7Thanks @Princesseuh! - Fix types not working properly when usingmoduleResolution: 'node16' -
#5060
5923dd77cThanks @AirBorne04! - api routes: adding cookies to the response, also when returning a simple result -
#5087
49a8d18b4Thanks @JuanM04! - Fixastro addpnpm command
1.5.0
Minor Changes
-
#5056
e55af8a23Thanks @matthewp! - # Adapter support forastro previewAdapters are now about to support the
astro previewcommand via a new integration option. The Node.js adapter@astrojs/nodeis the first of the built-in adapters to gain support for this. What this means is that if you are using@astrojs/nodeyou can new preview your SSR app by running:Adapter API
We will be updating the other first party Astro adapters to support preview over time. Adapters can opt-in to this feature by providing the
previewEntrypointvia thesetAdapterfunction inastro:config:donehook. The Node.js adapter's code looks like this:export default function() { return { name: '@astrojs/node', hooks: { 'astro:config:done': ({ setAdapter, config }) => { setAdapter({ name: '@astrojs/node', serverEntrypoint: '@astrojs/node/server.js', + previewEntrypoint: '@astrojs/node/preview.js', exports: ['handler'], }); // more here } } }; }The
previewEntrypointis a module in the adapter's package that is a Node.js script. This script is run whenastro previewis run and is charged with starting up the built server. See the Node.js implementation in@astrojs/nodeto see how that is implemented. -
#4986
ebd364e39Thanks @bluwy! - ## New properties for API routesIn API routes, you can now get the
site,generator,url,clientAddress,props, andredirectfields on the APIContext, which is the first parameter passed to an API route. This was done to make the APIContext more closely align with theAstroglobal in .astro pages.For example, here's how you might use the
clientAddress, which is the user's IP address, to selectively allow users.export function post({ clientAddress, request, redirect }) { if (!allowList.has(clientAddress)) { return redirect('/not-allowed'); } }
Check out the docs for more information on the newly available fields: https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes
-
#4959
0ea6187f9Thanks @Princesseuh! - Added support for updating TypeScript settings automatically when usingastro addThe
astro addcommand will now automatically update yourtsconfig.jsonwith the proper TypeScript settings needed for the chosen frameworks.For instance, typing
astro add solidwill update yourtsconfig.jsonwith the following settings, per Solid's TypeScript guide:{ "compilerOptions": { "jsx": "preserve", "jsxImportSource": "solid-js" } } -
#4947
a5e3ecc80Thanks @JuanM04! - - AddedisRestartandaddWatchFileto integration stepisRestart.- Restart dev server automatically when tsconfig changes.
-
#4986
ebd364e39Thanks @bluwy! - ## Support passing a custom status code for Astro.redirectNew in this minor is the ability to pass a status code to
Astro.redirect. By default it uses302but now you can pass another code as the second argument:--- // This page was moved return Astro.redirect('/posts/new-post-name', 301); ---
-
#5056
e55af8a23Thanks @matthewp! - # New build configurationThe ability to customize SSR build configuration more granularly is now available in Astro. You can now customize the output folder for
server(the server code for SSR),client(your client-side JavaScript and assets), andserverEntry(the name of the entrypoint server module). Here are the defaults:import { defineConfig } from 'astro/config'; export default defineConfig({ output: 'server', build: { server: './dist/server/', client: './dist/client/', serverEntry: 'entry.mjs', }, });
These new configuration options are only supported in SSR mode and are ignored when building to SSG (a static site).
Integration hook change
The integration hook
astro:build:startincludes a parambuildConfigwhich includes all of these same options. You can continue to use this param in Astro 1.x, but it is deprecated in favor of the newbuild.configoptions. All of the built-in adapters have been updated to the new format. If you have an integration that depends on this param we suggest upgrading to do this instead:export default function myIntegration() { return { name: 'my-integration', hooks: { 'astro:config:setup': ({ updateConfig }) => { updateConfig({ build: { server: '...', }, }); }, }, }; }
Patch Changes
-
#5057
baf88ee9eThanks @bluwy! - Skip JSX tagging for export statements with source -
#5044
44ea0c6d9Thanks @JuanM04! - Upgrade Astro compiler to 0.27.1 -
#5059
f7fcdfe62Thanks @bluwy! - Support strict dependency install for libraries with JSX -
#5047
1e2799243Thanks @matthewp! - Update Astro.cookies.set types to allow booleans and numbersNote that booleans and numbers were already allowed, they just were not allowed by the type definitions.
1.4.7
Patch Changes
-
#5035
d7bfb144bThanks @AirBorne04! - preventing multiple doctype injection into html documents -
#5015
b1964e9e1Thanks @matthewp! - Shared state in Preact components with signalsThis makes it possible to share client state between Preact islands via signals.
For example, you can create a signals in an Astro component and then pass it to multiple islands:
--- // Component Imports import Counter from '../components/Counter'; import { signal } from '@preact/signals'; const count = signal(0); --- <Count count={count} /> <Count count={count} />
-
#5036
38fdb4ca6Thanks @matthewp! - New algorithm for shorter CSS bundle names
1.4.6
Patch Changes
1.4.5
Patch Changes
-
#4981
1f890b336Thanks @matthewp! - Ensure dynamic tags have their slot instructions yielded -
#4886
61d26f335Thanks @yuhang-dong! - Fix: import.meta.env.BASE_URL will be '/' in client loaded component on dev mode -
#4973
c733d4fb8Thanks @bluwy! - Support Astro.slots.render for mdx -
#4918
a6bb2694bThanks @bluwy! - Refactor hydration path handling -
#4977
4f73b98aeThanks @tony-sull! - Fixes a bug that logged route cache warnings inastro dev -
#4887
37cb2fc02Thanks @Calvin-LL! - fix object styles not escaped -
#4990
8f9791d84Thanks @matthewp! - Upgrade Astro compiler to 0.26.0
1.4.4
Patch Changes
-
#4967
e6a881081Thanks @matthewp! - Final perf fix from 1.3.0 regressionA regression in rendering perf happened in 1.3.0. This is the final fix for the underlying issue.
1.4.3
Patch Changes
-
#4956
ee8dd424fThanks @matthewp! - Fix perf regression in SSR -
#4952
5bcd76e3aThanks @bluwy! - Refactor ViteConfigWithSSR type
1.4.2
Patch Changes
-
#4932
9898088c0Thanks @matthewp! - Prevent hydration mismatch in streaming SSR -
#4939
cf2bba1e4Thanks @natemoo-re! - Fix MDX error handling, preventing a memory leak
1.4.1
Patch Changes
- #4928
7690849a8Thanks @Princesseuh! - Fix module definition of Markdown and MDX files not being available outside Astro files
1.4.0
Minor Changes
-
#4907
01c1aaa00Thanks @matthewp! - Order Astro styles last, to override imported stylesThis fixes CSS ordering so that imported styles are placed higher than page/component level styles. This means that if you do:
--- import '../styles/global.css'; --- <style> body { background: limegreen; } </style>
The
<style>defined in this component will be placed below the imported CSS. When compiled for production this will result in something like this:/* /src/styles/global.css */ body { background: blue; } /* /src/pages/index.astro */ body:where(.astro-12345) { background: limegreen; }
Given Astro's 0-specificity hashing, this change effectively makes it so that Astro styles "win" when they have the same specificity as global styles.
-
#4876
d3091f89eThanks @matthewp! - Adds the Astro.cookies APIAstro.cookiesis a new API for manipulating cookies in Astro components and API routes.In Astro components, the new
Astro.cookiesobject is a map-like object that allows you to get, set, delete, and check for a cookie's existence (has):--- type Prefs = { darkMode: boolean; }; Astro.cookies.set<Prefs>( 'prefs', { darkMode: true }, { expires: '1 month', } ); const prefs = Astro.cookies.get<Prefs>('prefs').json(); --- <body data-theme={prefs.darkMode ? 'dark' : 'light'}></body>
Once you've set a cookie with Astro.cookies it will automatically be included in the outgoing response.
This API is also available with the same functionality in API routes:
export function post({ cookies }) { cookies.set('loggedIn', false); return new Response(null, { status: 302, headers: { Location: '/login', }, }); }
See the RFC to learn more.
Patch Changes
-
#4892
ff7ba0ee0Thanks @matthewp! - Prevent multiple rendering of head content -
#4842
812658ad2Thanks @bluwy! - Add missing dependencies, support strict dependency installation (e.g. pnpm) -
#4891
87a7cf48eThanks @matthewp! - Hoist hydration scripts out of slot templates -
Updated dependencies [
812658ad2,812658ad2]:- @astrojs/markdown-remark@1.1.3
- @astrojs/telemetry@1.0.1
1.3.1
Patch Changes
-
#4861
42fe8e0c7Thanks @rishi-raj-jain! - use const instead of let for define:vars -
#4878
90c207299Thanks @rishi-raj-jain! - add warning for post routes called when output is not server -
#4855
49ca9e129Thanks @matthewp! - Fix TS errors when not using skipLibCheck -
#4845
3389f0ce9Thanks @matthewp! - Prevent the root folder from being deleted during the build -
#4841
4b092269cThanks @rishi-raj-jain! - copy assets even if outDir is out of process.cwd() -
#4849
ee5fdeffdThanks @rishi-raj-jain! - append .html to the file URL in case build.format says file -
#4867
03e8b750aThanks @rishi-raj-jain! - check if class:list's value is defined before converting -
#4873
83ed1cc1fThanks @bluwy! - Prevent /undefined catch-all routes in dev -
#4454
6a1a17dd2Thanks @bluwy! - Allow HMR for internal e2e tests -
#4712
17dbc6701Thanks @Lifeni! - Fix slashes for paths containing non-ASCII characters on Windows -
#4850
edb7bead6Thanks @rishi-raj-jain! - add support for changing mode via CLI -
#4868
b99f9902bThanks @rishi-raj-jain! - remove all the ssr generated folders in static build if only empty -
Updated dependencies [
5e4c5252b]:- @astrojs/webapi@1.1.0
1.3.0
Minor Changes
-
#4775
b0cc93996Thanks @tony-sull! - Adds a new "astro:build:generated" hook that runs after SSG builds finish but before build artifacts are cleaned up. This is a very specific use case, "astro:build:done" is probably what you're looking for. -
#4669
a961aa3c2Thanks @aggre! - astro-island now correctly passes Uint8Array/Uint16Array/Uint32Array -
#4832
73f215df7Thanks @matthewp! - Allows Responses to be passed to set:htmlThis expands the abilities of
set:htmlto ultimate service this use-case:<div set:html={fetch('/legacy-post.html')} />
This means you can take a legacy app that has been statically generated to HTML and directly consume that HTML within your templates. As is always the case with
set:html, this should only be used on trusted content.To make this possible, you can also pass several other types into
set:htmlnow:Responseobjects, since that is what fetch() returns:<div set:html={new Response('<span>Hello world</span>', { headers: { 'content-type': 'text/html' }, })} />
ReadableStreams:<div set:html={new ReadableStream({ start(controller) { controller.enqueue(`<span>read me</span>`); controller.close(); }, })} />
AsyncIterables:<div set:html={(async function* () { for await (const num of [1, 2, 3, 4, 5]) { yield `<li>${num}</li>`; } })()} />
Iterables (non-async):<div set:html={(function* () { for (const num of [1, 2, 3, 4, 5]) { yield `<li>${num}</li>`; } })()} />
Patch Changes
-
#4831
29b29e6a8Thanks @yuhang-dong! - Update vite-jsx-plugin for jsx export -
#4754
baae1b3fdThanks @Princesseuh! - Updateastro checkto latest version of the language server
1.2.8
Patch Changes
-
#4813
be9eaa069Thanks @bluwy! - Allow overridevite.build.target -
#4817
a49bc2f02Thanks @mohammed-elhaouari! - fix parsing integration names with astro add command -
#4819
518e8f7e2Thanks @matthewp! - Allow passing promises to set:html -
#4807
44fa37818Thanks @lucacasonato! - Remove explicitTransfer-Encoding: chunkedheader from streaming responses -
#4803
f53d97d56Thanks @Enteleform! - replaces hard-codedminifyvalues withvite.build.minify -
Updated dependencies [
df54595a8]:- @astrojs/markdown-remark@1.1.2
1.2.7
Patch Changes
1.2.6
Patch Changes
1.2.5
Patch Changes
-
#4768
9a59e24e0Thanks @matthewp! - nsure before-hydration is only loaded when used -
#4759
fc885eaeaThanks @matthewp! - Read jsxImportSource from tsconfig
1.2.4
Patch Changes
-
#4736
13ca686eaThanks @bluwy! - Handle builds with outDir outside of current working directory -
#4748
c5e134d03Thanks @bluwy! - Fix console.error filtering -
#4742
cf8a7e933Thanks @matthewp! - Allow file uploads in dev server -
#4594
005d5bacdThanks @matthewp! - Allow custom 404 route to handle API route missing methods
1.2.3
Patch Changes
1.2.2
Patch Changes
-
#4705
5b6173fd0Thanks @Princesseuh! - Properly show an error message when a renderer is not properly configured -
#4723
0dba3b6f3Thanks @matthewp! - Makes the dev server more resilient to crashes
1.2.1
Patch Changes
- #4703
d28f7013cThanks @bholmesdev! - Fix: [astro add] Apply fetch polyfill before running
1.2.0
Minor Changes
-
#4682
d1e695914Thanks @bholmesdev! - astro add - move configuration updates to final step -
#4549
255636cc7Thanks @altano! - Allow specifying custom encoding when using a non-html route. Only option before was 'utf-8' and now that is just the default. -
#4578
c706d845eThanks @bholmesdev! - Restart dev server when config file is added, updated, or removed
Patch Changes
1.1.8
Patch Changes
-
#4675
63e49c3b6Thanks @matthewp! - Prevent locking up when encountering invalid CSS -
#4684
919df13b9Thanks @natemoo-re! - Fixes regression introduced in #4646 with better cyclic reference detection -
#4683
cc242d3afThanks @Princesseuh! - Fixtsccompilation errors whenskipLibCheckwasn't enabled -
#4667
9290b2414Thanks @Holben888! - Fix framework components on Vercel Edge -
#4645
f27ca6ab3Thanks @bholmesdev! - Fix client-side scripts reloads on dev server in windows
1.1.7
Patch Changes
-
#4646
98f242cdcThanks @natemoo-re! - Add cyclic ref detection when serializing props -
#4656
6d845c353Thanks @matthewp! - Fix bug with usingassertas import identifier -
#4403
d31e72c3bThanks @JohnDaly! - Fix for components, declared with JSXMemberExpression nodes, that failed to hydrate due to incomplete 'component-export' metadata
1.1.6
Patch Changes
-
#4623
eb1862b4eThanks @delucis! - Improve third-party Astro package support -
#4643
307b7b97cThanks @matthewp! - Remove regression when there is duplicate client/server CSS -
#4584
29a5fdc15Thanks @bluwy! - Correctly escape paths in file names -
#4621
0068afb87Thanks @AllanChain! - Ensure SSR module is loaded before testing if it's CSS in dev
1.1.5
Patch Changes
1.1.4
Patch Changes
-
#4586
16814dc71Thanks @bluwy! - Move ast-types as dev dependency -
#4585
f018e365cThanks @FredKSchott! - Add docs link to "missing adapter" error msg
1.1.3
Patch Changes
- #4574
b92c24f40Thanks @delucis! - Updateastro addto list official integrations & adapters with same organisation we use in docs
1.1.2
Patch Changes
-
#4519
a2e8e76c3Thanks @JuanM04! - Upgraded Shiki to v0.11.1 -
#4531
2d2e38e47Thanks @bluwy! - Remove hardcoded Vite middleware handling -
#4553
2f05f5d30Thanks @matthewp! - Include trailingSlash in astro:build:done hookThis change ensures that the
pagesprovided in theastro:build:donehook conform to thetrailingSlashandbuild.formatconfigs. -
#4526
046bfd908Thanks @bluwy! - Skip clean SSR output if page generation fails -
#4546
bb71be78dThanks @bholmesdev! - Update "Add an Adapter" help heading to "Add an SSR Adapter" -
#4548
69b640b87Thanks @bholmesdev! - Fix "failed to load for SSR" on styles when using tailwind -
#4535
ca28d7578Thanks @Princesseuh! - Add missingslotattributes to SVG definitions -
#4524
d431fbe4e- fix import in the config type declarations -
Updated dependencies [
a2e8e76c3]:- @astrojs/markdown-remark@1.1.1
1.1.1
Patch Changes
- #4507
4e1af3f0eThanks @Princesseuh! - Fiximport-meta.d.tsnot being included in the npm package
1.1.0
Minor Changes
- #4352
cd154e447Thanks @matthewp! - Make Astro.url match the build.format configuration during the build
- #4423
d4cd7a59fThanks @bholmesdev! - Update Markdown type signature to match new markdown plugin,and update top-level layout props for better alignment
- #4474
ac0321824Thanks @bholmesdev! - Add "extends" to markdown plugin config to preserve Astro defaults
Patch Changes
- #4500
9874c7bf4Thanks @Princesseuh! - Updateastro checkto use latest version of the Astro language server
- #4439
77ce6be30Thanks @Princesseuh! - Add tsconfig templates for users to extend from
- #4499
1f42c0791Thanks @Princesseuh! - Fixtscnot being able to find Vite's import.meta types on Linux
-
#4497
78e06c8ecThanks @bholmesdev! - Production build logging - Only log[code].htmlinstead of[code]/index.htmlfor 404 and 500 routes -
Updated dependencies [
ac0321824,839097c84]:- @astrojs/markdown-remark@1.1.0
1.1.0-next.0
Minor Changes
- #4352
cd154e447Thanks @matthewp! - Make Astro.url match the build.format configuration during the build
- #4423
d4cd7a59fThanks @bholmesdev! - Update Markdown type signature to match new markdown plugin,and update top-level layout props for better alignment
- #4474
ac0321824Thanks @bholmesdev! - Add "extends" to markdown plugin config to preserve Astro defaults
Patch Changes
-
#4439
77ce6be30Thanks @Princesseuh! - Add tsconfig templates for users to extend from -
Updated dependencies [
ac0321824,839097c84]:- @astrojs/markdown-remark@1.1.0-next.0
1.0.9
Patch Changes
- #4456
47e71ae8fThanks @Princesseuh! - Added an error message when the second argument of Astro.slots.render is not an array
1.0.8
Patch Changes
- #4427
b2e976f39Thanks @cameronmcefee! - Fix config types to allow falsy values in integrations list, to match docs
- #4385
8164fa6f1Thanks @krolebord! - Fix warning when using hooks inside the react components not exported as a function declaration
- #4445
df4e99928Thanks @bholmesdev! - Add "waiting for X integration" log for long-running integration hooks
- #4430
dc42f2c00Thanks @bholmesdev! - astro add - Fix third-party npm orgs, i.e.@example/integration
- #4441
ca0c7e8b8Thanks @Princesseuh! - Allow arbitrary strings on the target attribute
-
#4446
27ac6a03aThanks @matthewp! - Deterministic CSS orderingThis makes our CSS link order deterministic. It uses CSS depth; that is how deeply a module import the CSS comes from, in order to determine which CSS is page-level vs. component-level CSS.
This is intended to match dev ordering where, because we do not bundle, the page-level CSS always comes after component-level.
1.0.7
Patch Changes
- #4362
aa5118e85Thanks @joseph-lozano! - Allow user config to setmarkdown.draftsoption
- #4405
a70f69a06Thanks @FredKSchott! - Refactor JSX build plugin, improve performance
1.0.6
Patch Changes
- #4324
45fdbc465Thanks @BurntCaramel! - Use TextEncoder instead of Buffer.byteLength() for Deno compatibility
- #4329
0274b8d47Thanks @tony-sull! - Updates routing logic to allow multiple routes to match the same URL in SSR
- #4347
166b3b8a5Thanks @bholmesdev! - Fix MDXLayoutProps type signature for linting
1.0.5
Patch Changes
- #4302
1d3a0a16fThanks @FredKSchott! - Revert "Ensure hydration scripts inside of slots render ASAP (#4288)" to fix Svelte integration bug
- #4284
73f367c77Thanks @FredKSchott! - Prevent preview if 'output: server' is configured
1.0.4
Patch Changes
- #4268
f7afdb889Thanks @bholmesdev! - Align MD with MDX on layout props and "glob" import results:- Add
Contentto MDX - Add
fileandurlto MDX frontmatter (layout import only) - Update glob types to reflect differences (lack of
rawContentandcompiledContent)
- Add
- #4265
8f845ca95Thanks @matthewp! - Prevents automatic trailingSlash appending on getStaticPaths produced pages
- #4282
c0992e1feThanks @natemoo-re! - Fix bug where Astro's server runtime would end up in the browser
- #4272
24d2f7a6eThanks @natemoo-re! - Properly handle hydration for namespaced components
- #4289
3ca905174Thanks @bholmesdev! - [astro add] Setoutput: 'server'when adding adapter
1.0.3
Patch Changes
- #4279
42fd6936cThanks @FredKSchott! - Handle "not found" imports without throwing an "Invalid URL" error
- #4273
0022f46b5Thanks @Princesseuh! - Fix build output adding/index.htmlat the end of endpoints route
- #4270
7127b1bb3Thanks @natemoo-re! - Make third-party integration names nicer when usingastro add
1.0.2
Patch Changes
- #4240
561a34d91Thanks @matthewp! - Properly invalidate Astro modules when a child script updates in HMR
1.0.1
Patch Changes
3a7f2385eThanks @FredKSchott! - Add rawContent and compiledContent to MD layout props
1.0.0
Astro v1.0 is out! Read the official announcement post.
Note If you need help migrating an existing Astro project to the new Astro v1.0, check out our updated Migration Guide and full documentation website.
0.X
For older changelog entries -- including all v0.X, v1.0 Beta, and v1.0 Release Candidate versions -- check out the v0.X changelog.