@cloudconfig/nuxt

中文文档
0.4.0发布于 2026/11/05MITTypeScriptES Module近 30 天下载 2077

Nuxt module for CloudConfig — mounts the backend, resolves bindings per request, and ships a typed SSR-safe client.

原始使用文档
文档目录6 节
  1. Add CloudConfig to a Nuxt App
  2. Read Data in a Nuxt Page
  3. Use Sign-In
  4. Deploy Durable Workloads
  5. Change the Module Paths
  6. Share Feedback

@cloudconfig/nuxt

@cloudconfig/nuxt mounts a CloudConfig backend in Nuxt and provides typed composables for data and sign-in.

Install the official release with the latest npm dist-tag. Keep core and Nuxt on matching versions.

Add CloudConfig to a Nuxt App

Run the CLI from your Nuxt application directory:

npx -p @cloudconfig/core@latest cloudconfig init \
  --target nuxt \
  --cloudflare
pnpm install
pnpm db:generate
pnpm db:migrate
pnpm typecheck

The initializer adds the module, creates cloud.config.ts, and configures local SQLite. The --cloudflare option also prepares the Nuxt Worker build and wrangler.jsonc.

Read Data in a Nuxt Page

The module auto-imports useCloudConfig(). Pass the config type to get a client that follows your models:

<script setup lang="ts">
import type { config } from '~~/cloud.config'

const api = useCloudConfig<typeof config>()
const { data: posts } = await useAsyncData('posts', () => api.post.list())
</script>

During server rendering, the composable calls the backend inside Nitro and forwards the request cookies. In the browser, it calls the generated REST API.

Use Sign-In

When cloud.config.ts contains an auth block, the module also auto-imports useCloudConfigAuth():

<script setup lang="ts">
const auth = useCloudConfigAuth()

await auth.signIn.email({
  email: '[email protected]',
  password: 'correct-horse-battery-staple',
})
</script>

The signed-in user is available to the access rules in your config.

Deploy Durable Workloads

Set deploy.target to cloudflare, vercel, or azure in cloud.config.ts. The module selects the matching Nitro preset. Declare deploy.agent: { entry } or deploy.automations: { entry, schedules } to bind the selected cloud's native execution system. Install its optional runtime dependencies before building.

Authenticated server routes use useCloudConfigAgents(event) or useCloudConfigAutomations(event) with scopes derived from the session. cloudconfig deploy provisions native execution and synchronizes declared automation schedules after publication. Development uses process-local memory.

Vercel defaults to Turso; Cloudflare defaults to D1. See Deploy Agents, Deploy Automations, and Platform Support for setup and limits.

Change the Module Paths

Most applications do not need module options. Use them when the config or a custom identity resolver lives somewhere else.

Use cloud.config.ts; the legacy cloudconfig.config.ts name is also supported, including with a custom path. Without a custom path, the module checks the project root in that order, matching the CLI. Keep one config file. Both a named export const config = defineBackend(...) and export default defineBackend(...) work without exporting both. The generated starter uses the named export.

export default defineNuxtConfig({
  modules: ['@cloudconfig/nuxt'],
  cloudconfig: {
    config: 'cloud.config.ts',
    getUser: 'server/cloudconfig/user.ts',
    client: true,
  },
})

The API mount path, local database file, and D1 binding belong in cloud.config.ts. This keeps the CLI and Nuxt runtime on the same configuration.

Share Feedback

Report bugs and request features in the public issue tracker. The public repository hosts the CloudConfig showcase; the implementation is maintained in a separate private repository.

版本与发布记录

@cloudconfig/nuxt 共发布 14 个版本,首次发布于 2026/09/18;过去 12 个月发布了 14 个版本。

版本发布日期距今
0.4.0latest2026/11/054 天前
0.3.02026/11/054 天前
0.2.02026/10/2713 天前
0.2.0-beta.7beta2026/10/1624 天前
0.2.0-beta.62026/10/1625 天前
0.2.0-beta.52026/10/1625 天前

关于 @cloudconfig/nuxt 的常见问题

@cloudconfig/nuxt 是什么?

Nuxt module for CloudConfig — mounts the backend, resolves bindings per request, and ships a typed SSR-safe client.

如何安装 @cloudconfig/nuxt?

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

@cloudconfig/nuxt 支持 TypeScript 吗?

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

@cloudconfig/nuxt 支持 ESM 还是 CommonJS?

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

@cloudconfig/nuxt 需要什么版本的 Node.js?

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

@cloudconfig/nuxt 可以商用吗?

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

@cloudconfig/nuxt 的下载量有多少?

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

@cloudconfig/nuxt 还在维护吗?

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