Skip to content

Installation

Are you ready to install Astro? Follow this guide to get started using the astro CLI.

Let’s Start Our First Project

Requirements:

  • Node.js - Version 16.12.0 or higher.
  • VSCode - Astro.js recommends using its own extension with VSCode.
  • Terminal - Access Astro through the command-line interface (CLI). Open the terminal in a folder and enter the following code:
Terminal window
npm create astro@latest

After entering this code in the terminal, it will ask, “Where do you want to create your new project?” You can answer this with a (.) dot to choose your current folder. Then, it will ask, “What type of project would you like to start?” Options include:

  • Include Sample File = Creates ready-made template files in the folder. Ideal for getting started.
  • Use blog template = Creates a ready-made blog template with Markdown and MarkdownJS files.
  • Empty = Only creates an index file. If you’re already familiar with Astro, you can use this option to start from scratch.

In the next terminal screen, it will ask you, “Do you want to install dependencies?” You can choose between (Yes) or (No). You can navigate between options with arrow keys and select (Yes).

As the next option, it will ask if you want to use TypeScript. You can choose (Yes) or (No) in the same way. If you choose (No), it will allow you to install TypeScript later.

The next option asks if you want to create a GitHub repository. You can choose this option if you want to publish your code on GitHub.

Let’s Run Our Project

Open the terminal and enter the following code:

Terminal window
npm run dev

If everything goes well, Astro will run your project on a blank port like localhost:3000 or localhost:4321.

Astro listens to live file changes in your src/ directory, so you don’t need to restart the server while making changes during development.

If you encounter errors while running your project, you can check your package.json file.

Starter Templates

You can choose official Astro templates or create your own on GitHub.

For example, if you want to create a template named “astro-paper” that is published on GitHub:

Open the terminal and enter the following code:

Terminal window
npm create astro@latest -- --template satnaing/astro-paper

With this code, you can create a template you like from GitHub. You can click here for templates that Astro has published on its own site.