Official Prettier plugin for formatting Astro (.astro) files. Current stable version 0.14.1, released October 2024, with minor/patch releases every few months. Key differentiator: it's the official Astro team plugin, supporting Astro-specific syntax like frontmatter, components, and expressions. Alternatives like prettier-plugin-astro-organize-imports offer additional sorting. Requires Node ^14.15.0 || >=16.0.0 and Prettier >=3.0 (breaking change in v0.11.0).
npm install prettier-plugin-astroVerified import paths — ran on the pinned version, not inferred.
Installation and configuration of prettier-plugin-astro for formatting .astro files.
Upgrade Prettier to 3.x (npm i prettier@latest) or stick with prettier-plugin-astro <=0.10.0
Add overrides to your Prettier config: { files: '*.astro', options: { parser: 'astro' } }Use `astroAllowShorthand` in your Prettier config instead of the old CLI flag.
Review and re-format existing .astro files after upgrade.
Run `npm i --save-dev prettier prettier-plugin-astro` and ensure config has `plugins: ['prettier-plugin-astro']`.
Install a compatible version of Prettier: `npm i --save-dev prettier` (3.x recommended).
Add override for *.astro files with parser: 'astro' in your Prettier config.