You are reading Edgio v6 docs. Check out our latest docs for Edgio v7.
Edgio
Edgio

Astro

Astro is a modern static site builder. This guide walks you through deploying Astro sites to Edgio.

Example

Example SSR Site

This Astro example app uses server-side rendering.

Connector

This framework has a connector developed for Edgio. See Connectors for more information.

System Requirements

Sign up for Edgio

Deploying requires an account on Edgio. Sign up here for free.

Install the Edgio CLI

If you have not already done so, install the Edgio CLI.

Bash
1npm i -g @edgio/cli

Create your Astro site

If you don’t have an existing Astro site, you can create one by running:

Bash
1npm create astro@latest

Initializing your Project

Initialize your project for use with Edgio by running the following command in your project’s root directory:

Bash
1edgio init

This will automatically add all of the required dependencies and files to your project. These include:

  • The @edgio/core package
  • The @edgio/angular package
  • The @edgio/cli package
  • The @edgio/astro package
  • edgio.config.js - Contains various configuration options for Edgio.
  • routes.js - A default routes file that sends all requests to the Astro. Update this file to add caching or proxy some URLs to a different origin.

Routing

The default routes.js file created by edgio init sends all requests to Astro server via a fallback route.

JavaScript
1// This file was added by edgio init.
2// You should commit this file to source control.
3
4const {Router} = require('@edgio/core/router');
5const {astroRoutes} = require('@edgio/astro');
6
7export default new Router().use(astroRoutes);

Enable Server Side Rendering

Specify appPath inside edgio.config.js

After you’ve setup @astrojs/node with Astro, specify server file path in edgio.config.js as below:

JavaScriptedgio.config.js
1import {join} from 'path';
2
3module.exports = {
4 astro: {
5 appPath: join(process.cwd(), 'dist', 'server', 'entry.mjs'),
6 },
7 // Rest of the config
8};

If you’re using custom server file for enabling server side rendering, make sure your server is listening to port via process.env[‘PORT’].

Running Locally

To test your app locally, run:

Bash
1edgio run

You can do a production build of your app and test it locally using:

Bash
1edgio build && edgio run --production

Setting --production runs your app exactly as it will be when deployed to the Edgio cloud.

Deploy to Edgio

Deploy your app to the Sites by running the following commands in your project’s root directory:

Bash
1edgio deploy

See Deployments for more information.