Skip to content
Atlas Platform
GitHubDiscordYouTube

Astro Framework Guide

Introduction

Astro is a sever-first framework for creating fast content-focused sites. You can run the framework either in SSR or SSG mode, and you can incorporate any of the popular frontend frameworks, like React, Vue, Svelte, etc. Astro is best used for content-focused sites, not web applications. Check out their docs for some more details on when you should and should not use Astro in your project.

Deploy Steps

To get started, you can run the following command to create a new Astro project and the follow the steps in their installation guide:

npm create astro@latest

Or, if you want to start with a template designed specifically for headless WordPress, you can clone this starter template:

git clone https://github.com/JEverhart383/astro-wordpress-starter.git

After you have created your application, cd into your project directory:

cd <your project directory>

Push Initial Commits to Your Repository

To deploy your project to Atlas, it will need to be available on a remote GitHub, Bitbucket or GitLab repository. The Astro installation process lets to initialize a local repository for the project.

Create a new remote repository, and then run the following commands to initalize and configure your local and remote repositories:

#Add remote repository
$ git remote add origin https://<your-git-provider>/<username>/<repo>

# Stage all changed files
$ git add -A

# Commit the files to the current branch
$ git commit -m "initial commit"

# Push changes to remote repository
$ git push -u origin main

Build Details

Astro has two main rendering output modes, server or static, but using prerender flags you can implement a hybrid rendering approach.

First, add the @astrojs/node adapter using the following command:

$ npx astro add node

With that adapter installed, update the Astro config file to tell the Node adapter to run in standalone mode:

import { defineConfig } from 'astro/config';
import node from '@astrojs/node';

export default defineConfig({
  output: 'server',
  adapter: node({
    mode: 'standalone'
  }),
});

To commit these changes to your repository, run the following commands:

# Stage all changed files
$ git add -A

# Commit the files to the current branch
$ git commit -m "update build and start"

# Push changes to remote repository
$ git push -u origin main

Deploy Your Repository

Once your project is in a remote repository, you can follow the directions in our getting started guide to deploy your project to Atlas.

Best Practices

Since most Astro implementations use SSG to generate your site at build time, we recommend implementing WPGraphQL Smart Cache on your WordPress instance to improve server performance.

Was this page helpful?
👍 Yes  |  👎 No