create astro CLI command is the fastest way to start a new Astro project from scratch. It will walk you through every step of setting up your new Astro project and allow you to choose from a few different official starter templates.
You can also run the CLI command with the template flag to begin your project using any existing theme or starter template. Explore the themes and starters showcase where you can browse themes for blogs, portfolios, documentation sites, landing pages, and more!
Prerequisites
Before you begin, make sure you have the following installed:- Node.js -
v18.20.8orv20.3.0,v22.0.0or higher. (v19andv21are not supported.) - Text editor - We recommend VS Code with the Official Astro extension.
- Terminal - Astro is accessed through its command-line interface (CLI).
Browser compatibility
Astro is built with Vite which targets browsers with modern JavaScript support by default. For a complete reference, you can see the list of currently supported browser versions in Vite.Install from the CLI wizard
You can runcreate astro anywhere on your machine, so there’s no need to create a new empty directory for your project before you begin. If you don’t have an empty directory yet for your new project, the wizard will help create one for you automatically.
Run the install wizard
Run the following command in your terminal to start the install wizard:If all goes well, you will see a success message followed by some recommended next steps.
Navigate to your project
Now that your project has been created, you can
cd into your new project directory to begin using Astro.Install dependencies
If you skipped the “Install dependencies?” step during the CLI wizard, then be sure to install your dependencies before continuing.
CLI installation flags
You can run thecreate astro command with additional flags to customize the setup process or your new project.
Add integrations
You can start a new Astro project and install any official integrations or community integrations that support theastro add command at the same time by passing the --add argument.
Use a theme or starter template
You can start a new Astro project based on an official example or themain branch of any GitHub repository by passing a --template argument to the create astro command.
main branch. To use a different branch name, pass it as part of the --template argument: <github-username>/<github-repo>#<branch>.
Manual setup
This guide will walk you through the steps to manually install and configure a new Astro project if you prefer not to use the automaticcreate astro CLI tool.
Create your directory
Create an empty directory with the name of your project, and then navigate into it.Once you are in your new directory, create your project
package.json file. This is how you will manage your project dependencies, including Astro.Install Astro
First, install the Astro project dependencies inside your project.Then, replace any placeholder “scripts” section of your You’ll use these scripts later in the guide to start Astro and run its different commands.
package.json with the following:package.json
Create your first page
In your text editor, create a new file in your directory at
src/pages/index.astro. This will be your first Astro page in the project.For this guide, copy and paste the following code snippet (including --- dashes) into your new file:src/pages/index.astro
Create your first static asset
You will also want to create a
public/ directory to store your static assets. Astro will always include these assets in your final build, so you can safely reference them from inside your component templates.In your text editor, create a new file in your directory at public/robots.txt. robots.txt is a simple file that most sites will include to tell search bots like Google how to treat your site.For this guide, copy and paste the following code snippet into your new file:public/robots.txt
Create astro.config.mjs
Astro is configured using If you want to include UI framework components such as React, Svelte, etc. or use other tools such as MDX or Partytown in your project, here is where you will manually import and configure integrations.
astro.config.mjs. This file is optional if you do not need to configure Astro, but you may wish to create it now.Create astro.config.mjs at the root of your project, and copy the code below into it:astro.config.mjs
Add TypeScript support
TypeScript is configured using
tsconfig.json. Even if you don’t write TypeScript code, this file is important so that tools like Astro and VS Code know how to understand your project. Some features (like npm package imports) aren’t fully supported in the editor without a tsconfig.json file.If you do intend to write TypeScript code, using Astro’s strict or strictest template is recommended. You can view and compare the three template configurations at astro/tsconfigs/.Create tsconfig.json at the root of your project, and copy the code below into it. (You can use base, strict, or strictest for your TypeScript template):tsconfig.json