Astro
Astro is a modern open-source Web framework with broad influence in the Web development community, and it is a popular choice for building content-driven websites and applications.
Attention:
Supports Astro 5, 6, and 7, with Astro 7 recommended. Using Astro 7 requires @edgeone/astro 1.2.0 or later, and older versions of the adapter will report dependency conflicts during installation.
When Astro projects are deployed and run, the Makers platform runtime environment requires Node.js 22+. It is recommended to use an earlier Node.js version.
Core Features
Astro provides the following core features:
Islands Architecture: Astro adopts the Islands Architecture design, treating interactive components on the page as independent "islands" that are hydrated on the client side only when needed, while the rest remain static.
Server-Side Rendering (SSR): Astro's server-side rendering can render dynamic data without requiring client-side JavaScript, while not slowing down pages that do not need this feature.
Static Site Generation (SSG): Supports pre-rendering pages and generates static HTML at build time.
Multi-Framework Support: When using Astro, you can still use other frameworks (Vue, React, Svelte). It supports the mixed use of multiple framework components in the project.
Content Collections: Organize Markdown and MDX content with type-safe frontmatter.
API Routes: Server-side API endpoints for dynamic data processing.
Getting Started
You can quickly deploy an Astro project on EdgeOne Makers in the following ways:
Import an Astro project from a Git repository.
Select an Astro template from the Makers template library to deploy.
To learn how Astro performs when deployed on Makers, click the Astro sample template from Makers below:
Makers' Support for Astro Features
The following table lists the key features that Makers currently supports for Astro:
Astro Feature | Support Status |
Islands architecture rendering | ✓ |
Server-side rendering (SSR) | ✓ |
Static site generation (SSG) | ✓ |
Multi-framework support | ✓ |
Content collections (MD, MDX) | ✓ |
API routing | ✓ |
Actions routing | ✓ |
Middleware | Supports Astro built-in middleware |
Image component | Not supported. |
Platform ISR | Not supported. |
Unsupported Astro features are currently being planned on the Makers platform. It is recommended to follow the version updates of the @edgeone/astro adapter to get the latest features and improvements in a timely manner.
Deploying an Astro Project on Makers
1. Installing the Astro Adapter for Makers
The Astro adapter for Makers is named
@edgeone/astro. It automatically adapts the build output of Astro applications for the Makers platform. Similar to @astrojs/vercel, it works with the Makers scaffolding tool to package and deploy local Astro projects to the Makers platform. The adapter source code is open source. You are welcome to visit the astro-adapter repository to view the source code, submit issues, or contribute.The following is the installation command for the adapter:
npm install @edgeone/astro
2. Configuring astro.config.mjs
According to the Astro configuration file API, users need to configure the Makers platform adapter in the
astro.config.mjs file of the Astro project. The following is a configuration example:import { defineConfig } from "astro/config";import edgeoneAdapter from "@edgeone/astro";export default defineConfig({adapter: edgeoneAdapter(),});
3. Deploying the Project
Deploying via Git Connection
After seamless integration of the adapter, you can submit the project to platforms such as GitHub and GitLab and use our Import Git Repo.
CLI Deployment
You can also install the Makers scaffolding tool. For detailed installation and usage instructions, see EdgeOne CLI. After configuration, use the `edgeone makers deploy` command to deploy the project. During deployment, the CLI automatically builds the project first, and then uploads and publishes the build artifacts.
Attention:
EdgeOne CLI version requirement ≥ 1.2.4. Please first check the version before deployment to avoid deployment failure.
Configuring the Makers Adapter for Astro
The adapter supports the following configuration options:
outDir (optional): Specifies the build output directory, with a default value of .edgeone. Example: outDir: ".edgeone".includeFiles (optional): A mandatory inclusion file list used to underwrite specific files is packaged into server-side rendering code. Supports glob pattern matching. Example: includeFiles: ["src/locales/**", "public/config.json"].excludeFiles (optional): A list of files to exclude from being packaged into server-side rendering code. It is mainly used to exclude specific files in node_modules. Supports glob pattern matching. Example: excludeFiles: ["node_modules/.cache/**"].The following is a configuration example:
import { defineConfig } from "astro/config";import edgeoneAdapter from "@edgeone/astro";export default defineConfig({output: "server",adapter: edgeoneAdapter({outDir: ".edgeone",includeFiles: ["src/locales/**"],excludeFiles: ["node_modules/.cache/**"],}),});
Static Site Generation (SSG)
You can use Astro to generate a fully static site. To configure static export mode, modify astro.config.mjs as shown in the following example:
export default defineConfig({output: 'static' // Enable static export});
Note: In Astro's SSG (Static Site Generation) mode, all pages are pre-rendered as static HTML at build time. There is no server runtime, so server-side features cannot be used, including API routes (src/pages/api/*), middleware (src/middleware.ts), and any other features that require server-side execution.
Server-Side Rendering (SSR)
The Makers adapter also supports Astro's server-side rendering feature. To enable SSR mode, set the following configuration in
astro.config.mjs:export default defineConfig({output: 'server' // Enable server-side rendering});
In SSR mode, allow you to dynamically generate HTML content on the server side, provides better SEO support, faster page load speed, and real-time rendering capability for dynamic content.
In addition to pure SSR mode, Makers also supports Astro's hybrid mode. In hybrid mode, you can flexibly control the rendering method of each page:
Static page: Set
export const prerender = true in the page, and the page will be pre-rendered as a static HTML file at build time.Dynamic page: Pages where
prerender is not set to true will be dynamically rendered using SSR.Incremental Static Regeneration (ISR)
Incremental Static Regeneration is an extension of SSG that combines the advantages of SSG and SSR, eliminating the need to rebuild the entire site when data is updated. Astro does not provide page-level ISR exports, so you can enable it in the adapter's
isr option in astro.config.mjs (effective only for SSR routes that are not pre-rendered). Use expiration (in seconds) to set the regeneration interval for routes: when a visitor requests a route after the cache expires, the old version is returned first while the page is regenerated in the background.import { defineConfig } from "astro/config";import edgeoneAdapter from "@edgeone/astro";export default defineConfig({output: "server",adapter: edgeoneAdapter({isr: {routes: {// Revalidate every 60 seconds"/blog/**": { expiration: 60 },},},}),});
