@datocms/astro

中文文档
0.7.0发布于 2026/11/10MITES Module近 30 天下载 5378

A set of components and utilities to work faster with DatoCMS in Astro projects.

原始使用文档
文档目录4 节
  1. Features
  2. Installation
  3. Releasing (maintainers)
  4. Trying a change before it's released

👉 Visit the DatoCMS homepage or see What is DatoCMS?


@datocms/astro

MIT NPM

A set of TypeScript-ready components and utilities to work faster with DatoCMS in Astro project. Integrates seamlessly with DatoCMS's GraphQL Content Delivery API.

Features

@datocms/astro contains ready-to-use Astro components and helpers:

Installation

npm install @datocms/astro

Releasing (maintainers)

Every user-visible change needs a changeset: run npx changeset from the repo root in the same PR, pick the bump level (patch is for bug fixes only, new API surface is minor) and commit the file it writes under .changeset/. That is where the changelog entry comes from, and it is where the bump level is decided — not on release day. See .changeset/README.md.

To release, from an up-to-date, clean main, run npm run release. It builds and tests, applies the pending changesets — bumping the version and writing CHANGELOG.md — publishes to npm, and only then tags vX.Y.Z, pushes, and creates a GitHub release whose notes come straight from that changelog entry. An interrupted release is resumed by re-running it, never undone. Use npm run release:next for a prerelease under the next dist-tag.

The script is @datocms/release-toolchain, shared with every other DatoCMS repository and pinned here by tag.


Trying a change before it's released

Every push to a branch here publishes a preview of the package, which you can install anywhere — no npm release, no npm link:

npm i https://pkg.pr.new/datocms/astro-datocms/@datocms/astro@<commit-sha>

The exact URL shows up in the commit's check run on GitHub, and in a comment on the pull request once there is one. This is the supported way to try a change inside a site that lives in another repository, or to hand a fix to whoever reported it before it is released.

Previews are throwaway: they are never published to npm, and the URL stops resolving after a while. Never commit one to a package.json that ships.

What is DatoCMS?

DatoCMS - The Headless CMS for the Modern Web

DatoCMS is Headless CMS for the modern web. Trusted by 25,000+ businesses, agencies, and individuals, it gives your team one place to manage content and ship it to any website, app, or device via API.

New here? Start with Create free account and the Documentation. Stuck? Ask the Community. Curious what's new? Product Updates.

Building with AI: Agent Skills turn coding assistants (Claude Code, Cursor) into expert DatoCMS developers, with full read/write via the auto-installed CLI. No local terminal? Use the MCP Server instead.

Talking to DatoCMS from code:

  • Content Delivery API (CDA) — the fast, read-only GraphQL API your website/app uses to fetch published content.
  • Content Management API (CMA) — the REST API for creating and updating content, models, and project settings (think scripts, migrations, integrations).
  • CLI — terminal tool for schema migrations and importing from Contentful/WordPress.

Framework guides: end-to-end recipes for fetching content, rendering Structured Text, optimizing images/video, handling SEO, and setting up live preview with visual editing in Next.js, Nuxt, Svelte, and Astro.

Want a head start? Browse our starter projects — ready-to-deploy example sites for popular frameworks.

版本与发布记录

@datocms/astro 共发布 48 个版本,首次发布于 2024/08/05;过去 12 个月发布了 15 个版本。

版本发布日期距今
0.7.0latest2026/11/101 天前
0.6.162026/09/032 个月前
0.6.152026/08/312 个月前
0.6.142026/08/103 个月前
0.6.132026/06/124 个月前
0.6.122026/03/237 个月前

其他发布通道:next → 0.6.6。

关于 @datocms/astro 的常见问题

@datocms/astro 是什么?

A set of components and utilities to work faster with DatoCMS in Astro projects.

如何安装 @datocms/astro?

在项目目录运行 npm install @datocms/astro,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:astro(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@datocms/astro 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/datocms__astro 是否存在。

@datocms/astro 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@datocms/astro 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@datocms/astro 可以商用吗?

@datocms/astro 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@datocms/astro 的下载量有多少?

根据 npm 官方下载统计,@datocms/astro 在 2026/10/12 – 2026/11/10 这 30 天内被下载 5,378 次,日均约 179 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@datocms/astro 还在维护吗?

最新版本 0.7.0 发布于 2026/11/10(1 天前);至今共发布 48 个版本,其中过去 12 个月发布了 15 个;首次发布于 2024/08/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。