Skip to content

astro

Editor setup

Astro

Editor setup

Editor setup

See how to set up TypeScript in your Astro project.

Zed

Zed is a high-performance, multiplayer code editor that is optimized for speed and large projects. Their Astro extension includes features like syntax highlighting for .astro files, code completion, formatting, diagnostics, and go-to-definition.

JetBrains IDEs

Webstorm is a JavaScript and TypeScript IDE that added support for the Astro Language Server in version 2024.2. This update brings features like syntax highlighting, code completion, and formatting.

Install the official plugin through JetBrains Marketplace or by searching for "Astro" in the IDE's Plugins tab. You can toggle the language server in Settings | Languages & Frameworks | TypeScript | Astro.

For more information on Astro support in Webstorm, check out the official Webstorm Astro Documentation.

Other Code Editors

Our amazing community maintains several extensions for other popular editors, including:

In-Browser Editors

In addition to local editors, Astro also runs well on in-browser hosted editors, including:

  • StackBlitz and CodeSandbox - online editors that run in your browser, with built-in syntax highlighting support for .astro files. No installation or configuration required!
  • GitHub.dev - allows you to install the Astro VS Code extension as a web extension, which gives you access to only some of the full extension features. Currently, only syntax highlighting is supported.

Other tools

ESLint

ESLint is a popular linter for JavaScript and JSX. For Astro support, a community maintained plugin can be installed.

See the project's User Guide for more information on how to install and set up ESLint for your project.

Stylelint

Stylelint is a popular linter for CSS. A community maintained Stylelint configuration provides Astro support.

Installation instructions, editor integration, and additional information can be found in the project's README.

Biome

Biome is an all-in-one linter and formatter for the web. Biome currently has experimental support for .astro files, and can be used to lint and format the frontmatter in .astro files.

Prettier

Prettier is a popular formatter for JavaScript, HTML, CSS, and more. If you're using the Astro VS Code Extension, code formatting with Prettier is included.

To add support for formatting .astro files outside of the editor (e.g. CLI) or inside editors that don't support our editor tooling, install the official Astro Prettier plugin.

1. Install `prettier` and `prettier-plugin-astro`.
<PackageManagerTabs>
  <Fragment slot="npm">
  ```shell
  npm install --save-dev --save-exact prettier prettier-plugin-astro
  ```
  </Fragment>
  <Fragment slot="pnpm">
  ```shell
  pnpm add --save-dev --save-exact prettier prettier-plugin-astro
  ```
  </Fragment>
  <Fragment slot="yarn">
  ```shell
  yarn add --dev --exact prettier prettier-plugin-astro
  ```
  </Fragment>
</PackageManagerTabs>
  1. Create a .prettierrc configuration file (or .prettierrc.json, .prettierrc.mjs, or other supported formats) in the root of your project and add prettier-plugin-astro to it.

    In this file, also manually specify the parser for Astro files.

    {
      "plugins": ["prettier-plugin-astro"],
      "overrides": [
        {
          "files": "*.astro",
          "options": {
            "parser": "astro"
          }
        }
      ]
    }
  2. Optionally, install other Prettier plugins for your project, and add them to the configuration file. These additional plugins may need to be listed in a specific order. For example, if you use Tailwind, prettier-plugin-tailwindcss must be the last Prettier plugin in the plugins array.

    {
      "plugins": [
        "prettier-plugin-astro",
        "prettier-plugin-tailwindcss" // needs to be last
      ],
      "overrides": [
        {
          "files": "*.astro",
          "options": {
            "parser": "astro"
          }
        }
      ]
    }
  3. Run the following command in your terminal to format your files.

    ```shell npx prettier . --write ``` ```shell pnpm exec prettier . --write ``` ```shell yarn exec prettier . --write ```

See the Prettier plugin's README for more information about its supported options, how to set up Prettier inside VS Code, and more.

dprint

dprint is a highly-configurable code formatter that supports many languages, including JavaScript, TypeScript, CSS, and more. Support for .astro files can be added using the markup_fmt plugin.