Skip to content

Astro

ACMS integrates naturally with Astro. Since Astro components render at build time by default, ACMS fields are resolved during the build and baked into the output HTML.

Terminal window
npm install @useacms/client @useacms/cli

Use acms directly in Astro component frontmatter and templates:

src/pages/index.astro
---
import { acms } from '@useacms/client';
---
<html>
<body>
<h1>{acms.hero.title}</h1>
<p>{acms.hero.subtitle}</p>
<a href={acms.hero.ctaLink}>{acms.hero.ctaText}</a>
</body>
</html>

Fields are automatically registered when Astro renders the page during development.

src/components/Header.astro
---
import { acms } from '@useacms/client';
---
<header>
<nav>
<a href="/">{acms.site.name}</a>
</nav>
</header>
src/layouts/Base.astro
---
import { acms } from '@useacms/client';
const { title } = Astro.props;
---
<html>
<head>
<title>{title} | {acms.site.name}</title>
</head>
<body>
<header>
<nav>{acms.site.name}</nav>
</header>
<main>
<slot />
</main>
<footer>
<p>{acms.footer.copyright}</p>
</footer>
</body>
</html>

Astro supports embedding React, Vue, Svelte, and other framework components. ACMS works in all of them:

src/pages/index.astro
---
import ReactHero from '../components/Hero.jsx';
import VueFeatures from '../components/Features.vue';
---
<ReactHero client:load />
<VueFeatures client:visible />
src/components/Hero.jsx
import { acms } from '@useacms/client';
export default function Hero() {
return <h1>{acms.hero.title}</h1>;
}

Create acms.config.ts in your project root:

import { defineConfig } from '@useacms/client';
import { localFile, vercelEdgeConfig } from '@useacms/cli/adapters';
export default defineConfig({
dev: localFile({ path: './acms.json' }),
production: vercelEdgeConfig({
token: process.env.VERCEL_TOKEN,
}),
strategy: 'build-time',
});

For Astro sites, build-time strategy is usually the best choice since Astro renders pages at build time by default.

Terminal window
# Terminal 1
acms dev
# Terminal 2
astro dev

Or use a concurrent script:

{
"scripts": {
"dev": "concurrently \"acms dev\" \"astro dev\""
}
}
---
import { acms } from '@useacms/client';
---
<ul>
{acms.features.map((feature) => (
<li>{feature}</li>
))}
</ul>
---
import { acms } from '@useacms/client';
---
<img src={acms.hero.image} alt={acms.hero.imageAlt} />

If you’re using Astro in SSR mode (output: 'server'), you can use the runtime strategy for dynamic content:

export default defineConfig({
strategy: 'runtime',
});

This fetches content on each request rather than at build time.