@datocms/svelte

中文文档
4.2.16发布于 2026/09/03MITTypeScriptES Module近 30 天下载 5157

A set of components and utilities to work faster with DatoCMS in Svelte

原始使用文档
文档目录7 节
  1. Table of Contents
  2. Features
  3. Installation
  4. Development
  5. Building
  6. Releasing (maintainers)
  7. Trying a change before it's released

👉 Visit the DatoCMS homepage or see What is DatoCMS?


@datocms/svelte

MIT NPM Build Status

A set of components to work faster with DatoCMS in Svelte projects.

  • Works with Svelte and SvelteKit;
  • Written in TypeScript;
  • Usable both client and server side;

Table of Contents

Features

@datocms/svelte contains ready-to-use Svelte components and usage examples.

Components:

Stores:

Installation

npm install @datocms/svelte

Development

This repository contains some examples in the app/routes folder. You can use them to locally test your changes to the package:

npm run dev

Building

To create a production version of this library:

npm run build

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/datocms-svelte/@datocms/svelte@<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/svelte 共发布 46 个版本,首次发布于 2023/03/16;过去 12 个月发布了 14 个版本。

版本发布日期距今
4.2.16latest2026/09/032 个月前
4.2.152026/08/312 个月前
4.2.142026/06/154 个月前
4.2.132026/06/124 个月前
4.2.122026/03/237 个月前
4.2.112026/02/258 个月前

其他发布通道:next → 4.2.6。

关于 @datocms/svelte 的常见问题

@datocms/svelte 是什么?

A set of components and utilities to work faster with DatoCMS in Svelte

如何安装 @datocms/svelte?

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

@datocms/svelte 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@datocms/svelte 支持 ESM 还是 CommonJS?

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

@datocms/svelte 可以商用吗?

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

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

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

@datocms/svelte 还在维护吗?

最新版本 4.2.16 发布于 2026/09/03(2 个月前);至今共发布 46 个版本,其中过去 12 个月发布了 14 个;首次发布于 2023/03/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。