kreftjs

中文文档
0.0.11-beta发布于 2026/11/04Elastic-2.0TypeScriptCommonJS零依赖

A tiny reactive framework with its own component language (.kreft files): router with nested routes, stores, saved data, animations, an API client, hot reload, DevTools and a template engine.

原始使用文档
文档目录7 节
  1. Start in a minute
  2. What is inside
  3. Learn more
  4. The demo
  5. Repository layout
  6. Security
  7. License

Kreft

A small reactive framework with its own component language, and a full Node.js backend to go with it.

You write components in .kreft files in plain words: state, derive, action. The same project also gives you routing, controllers, an Active Record ORM, migrations, queues, mail, sign-in pages with two-factor codes, and a development server with hot reload that keeps your state.

📖 Read the documentation · run npm run dev and open /demo/docs for the searchable version.

<!-- Counter.kreft -->
state count = 0
derive double = count * 2
action add() { count++ }

<view>
  <button @click={add}>{count} × 2 = {double}</button>
</view>

Start in a minute

You need Node.js 22.5 or newer.

npm i -g kreftjs          # once: makes the `kreft` command available everywhere
kreft new my-app        # asks: JavaScript or TypeScript?
cd my-app
npm run dev

Open the address in the terminal (normally http://localhost:8000). A new project already has sign-in, registration, password reset, a dashboard and a profile page. The development database has a test user, [email protected] with the password password, for local use only.

What is inside

The .kreft languagestate, derive, action, watch, prop, event, slots, stores, saved data, load for APIs, forms with validation, animations.
RouterNested routes, layouts, guards, error pages, clean URLs.
BackendRoute, controllers, form requests, policies, models with relations, soft deletes and scopes, migrations, seeders, factories, jobs, mail, notifications, cache, Redis, file storage, scheduling.
AuthenticationCookie sessions with CSRF protection, API tokens with permissions, device list, two-factor codes, email verification, account lockout.
Toolingkreft dev with hot reload, DevTools, an error monitor, kreft build (CSP-safe), prerendering, TypeScript, Vite and Electron support, a safer kreft add, an MCP server for AI agents.

Learn more

I want to…Read
Build my first pageYour first app and Components
Fetch data and handle formsFetching data, Forms
Add an API and a databaseRouting, Models, Migrations
Understand sign-inAuthentication
Go to productionBuild and deploy, Production checklist
Look up a commandCommand line, then kreft list

The demo

In this repository, npm run dev serves live examples of every feature at http://localhost:8000/demo/: components, forms, loops, animations, the router and layouts, a database page, the backend, and the searchable documentation at /demo/docs.

Repository layout

kreftjs.js, kreftjs.d.ts  the browser runtime and its TypeScript types
server.js, server.d.ts    the backend entry point: require('kreftjs/server')
bin/                      the `kreft` command and the backend modules (bin/backend/)
tools/                    hot reload client, DevTools, Vite plugin
templates/app/            the project that `kreft new` creates
editors/vscode/           syntax colours and snippets for .kreft files
demo/                     the interactive demo
docs/                     the manual (README.md) and its viewer (Docs.kreft)
test/                     security regression tests: npm test

Security

Views are escaped, logins use HttpOnly cookies with CSRF protection, passwords use scrypt, and kreft dev only answers your own computer. The manual has a Security overview and a Production checklist. Run npm test to run the security regression tests.

License

Kreft is released under the Elastic License 2.0. You may use it, including to build and sell your own applications, copy it and change it. You may not offer Kreft itself to others as a hosted or managed service, and you may not remove or hide its license notices.

版本与发布记录

kreftjs 共发布 11 个版本,首次发布于 2026/11/03;过去 12 个月发布了 11 个版本。

版本发布日期距今
0.0.11-betalatest2026/11/041 天前
0.0.10-beta2026/11/041 天前
0.0.9-beta2026/11/041 天前
0.0.7-beta2026/11/041 天前
0.0.6-beta2026/11/041 天前
0.0.5-beta2026/11/041 天前

关于 kreftjs 的常见问题

kreftjs 是什么?

A tiny reactive framework with its own component language (.kreft files): router with nested routes, stores, saved data, animations, an API client, hot reload, DevTools and a template engine.

如何安装 kreftjs?

在项目目录运行 npm install kreftjs,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 kreft、kreftjs,可以用 npx kreft 直接运行。

kreftjs 支持 TypeScript 吗?

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

kreftjs 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

kreftjs 可以商用吗?

kreftjs 使用 Elastic-2.0 许可。声明的许可为 Elastic-2.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

kreftjs 还在维护吗?

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