@k2b/cloud

中文文档
0.52.0发布于 2026/11/01AGPL-3.0-or-laterES Module构建来源已验证

Application platform library for independently deployed Hono and SolidJS services behind a dynamic gateway.

原始使用文档
文档目录6 节
  1. Install
  2. Quick start
  3. Public building blocks
  4. Documentation
  5. Security
  6. License

Cloud

@k2b/cloud

Modular Hono+SolidJS framework for building per-app docker services behind a dynamic gateway.

The runtime that powers github.com/k2b-dev/cloud — an application platform that runs on infrastructure you operate, where every feature ships as its own Bun container, registers with a gateway through Redis, and inherits a shared session, UI kit, settings store, search, logging, email, websockets, and admin surface.

Install

bun add @k2b/cloud

The package is published as .ts source. It is intended for Bun consumers.

Quick start

// packages/my-app/src/config.ts
import { defineApp } from "@k2b/cloud";

export const app = defineApp({
  id: "my-app",
  name: "My App",
  icon: "ti ti-rocket",
  description: "What this app does",
  basePath: "/app/my-app",
  baseUrl: "http://app-my-app:3000",
  nav: { href: "/app/my-app", section: "more", requiresAuth: true },
  routes: ["/api/my-app", "/app/my-app", "/admin/my-app", "/public/my-app"],
});

export const { ssr, plugin } = app;
// packages/my-app/src/index.ts
import { app } from "./config";
import { Hono } from "hono";

export default await app.start({
  routes: {
    api: new Hono().get("/", (c) => c.json({ ok: true })),
    pages: new Hono().get("/", ...ssr(() => () => <div>hello</div>)),
  },
});

A standard app declares four prefixes (/api/<id>, /app/<id>, /admin/<id>, /public/<id>); the gateway routes them to your container by URL prefix from a Redis-backed registry.

Public building blocks

ImportUse for
@k2b/clouddefineApp, common types
@k2b/cloud/serverserver context, auth, route helpers
@k2b/cloud/browsertyped browser client
@k2b/cloud/servicessettings, logging, notifications, search
@k2b/cloud/contractsshared public contracts
@k2b/cloud/ssrCloud SSR helpers and islands
@k2b/cloud/workflowsdurable, inspectable application workflows
@k2b/cloud/aiAI and tool-calling contracts
@k2b/cloud/cliapplication CLI commands
@k2b/cloud/configdocumented configuration helpers
@k2b/uiPortable UI components and application layouts
@k2b/stdlib/solidowner-local queries, mutations, and interaction primitives
@k2b/ssrportable SolidJS SSR, islands, and navigation
@k2b/syncdistributed coordination, jobs, queues, and schedulers
@k2b/cloud/access/uiCloud access and resource-key controls
@k2b/cloud/account/uiCloud account selectors and avatars
@k2b/cloud/ai/uiCloud AI protocol adapters
@k2b/cloud/styles/global.cssbase Tailwind stylesheet

Documentation

Application setup, public contracts, and deployment guidance:

Security

Report a vulnerability privately through GitHub Security Advisories, never in a public issue. Security fixes appear in this package's changelog, and a published advisory names the first patched version. See the security policy.

License

GNU Affero General Public License v3.0 or later.

Commercial use, hosting, modification, and redistribution are permitted under the AGPL. If you modify Cloud and let users interact with it over a network, you must provide those users access to the corresponding source code under the same license.

Separate commercial licenses for proprietary, reseller, managed-service, white-label, or embedded product use are available by contacting the maintainer.

See the repository LICENSE file.

版本与发布记录

@k2b/cloud 共发布 54 个版本,首次发布于 2026/09/10;过去 12 个月发布了 54 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.52.0latest2026/11/012 天前
0.51.02026/11/012 天前
0.50.02026/11/012 天前
0.49.02026/11/012 天前
0.48.02026/10/313 天前
0.47.02026/10/313 天前

关于 @k2b/cloud 的常见问题

@k2b/cloud 是什么?

应用程序平台库,用于独立部署Hono和SolidJS服务,背后是一个动态网关。

如何安装 @k2b/cloud?

在项目目录运行 npm install @k2b/cloud,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:zod(^4.3.4)、hono(^4.12.25)、solid-js(^1.9.10)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@k2b/cloud 支持 TypeScript 吗?

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

@k2b/cloud 支持 ESM 还是 CommonJS?

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

@k2b/cloud 可以商用吗?

@k2b/cloud 使用 AGPL-3.0-or-later 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@k2b/cloud 还在维护吗?

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