@cratis/arc.vite

中文文档
22.184.0发布于 2026/11/10MITTypeScriptESM + CJS构建来源已验证近 30 天下载 3.9万

Vite helpers for Cratis Arc applications — metadata and query plugins for the generated TypeScript proxies of the CQRS framework for ASP.NET Core.

原始使用文档
文档目录13 节
  1. title: "Cratis Arc: CQRS framework for ASP.NET Core" descri…
  2. Start here
  3. What Arc owns
  4. Choose a path
  5. Arc does not require event sourcing
  6. Relationship to Components
  7. Start an Arc host
  8. Packages and repository layout
  9. Documentation map
  10. Contributing
  11. Trim and NativeAOT diagnostics
  12. Community and repository
  13. The Cratis ecosystem

title: "Cratis Arc: CQRS framework for ASP.NET Core" description: Cratis Arc is a CQRS framework for ASP.NET Core that exposes commands and queries over HTTP and generates TypeScript clients, without requiring event sourcing.

Cratis Arc: CQRS framework for ASP.NET Core

Cratis Arc is an open-source (MIT) CQRS application framework for ASP.NET Core. CQRS separates requests to change something (commands) from requests to read it (queries). Arc exposes those contracts over HTTP, handles validation and authorization, and generates TypeScript clients for the frontend. It works with current-state storage or optional Cratis Chronicle event sourcing.

Build a feature as a vertical slice: keep its command, read model, query, frontend, and specs together. The backend defines the contracts; generated TypeScript proxies carry them into the frontend without a hand-written API client for those contracts. Observable queries let a screen subscribe to results as they change, with a configured observation source.

Choose the packages your feature needs. Arc includes identity and tenancy, React integration, MongoDB and Entity Framework Core adapters, OpenAPI, analyzers, and testing helpers. Chronicle event sourcing and Cratis Components are optional integrations. Free AI skills provide guidance for building with the stack.

NuGet NPM .NET Build JavaScript Build

Start here

What Arc owns

BoundaryArc provides
HostingASP.NET Core hosting plus an Arc.Core HTTP host for workers, consoles, and custom services
CommandsModel-bound and controller-based execution, validation, authorization, filters, scopes, typed results, and generated endpoints
QueriesModel-bound and controller-based reads, paging and sorting, observable updates, WebSocket or Server-Sent Events transport, and query diagnostics
ValidationData annotations, FluentValidation, concept/command/query validators, generated client rules, and optional server preflight from React forms
Identity and tenancyPluggable authentication, identity details, role-based authorization, and header, query, claim, subdomain, fixed, or development tenant resolution
Generated contractsTypeScript proxies, referenced types, validation metadata, identity details, incremental output cleanup, and package/type mapping
Frontend packagesTypeScript command/query runtimes, React hooks and forms, dialogs, observable-query composition, and optional React/MVVM integration
Persistence integrationMongoDB and Entity Framework Core current-state adapters plus optional Chronicle-backed event-sourced behavior
Evaluation and toolingOpenAPI, runtime introspection, analyzers, source generators, command scenarios, proxy-generation checks, Vite helpers, and ESLint rules

Use this table to find the capability you need, then check its package and documentation for your host, provider, browser, and versions. The rows do not establish compatibility for every combination.

Choose a path

Arc documentation is organized around the job you need to complete:

For a first feature, start the host below, then follow the command and query guides. If you already have an application, choose the path for the part you want Arc to handle.

Arc does not require event sourcing

Arc.Core does not depend on Chronicle. A command can call an application service or write current state to a database; a query can read that state without an event log.

Choose the optional Chronicle integration when you want to record events and derive state from them. Arc still handles commands, queries, validation, authorization, and generated frontend contracts.

Chronicle is Cratis's storage-agnostic event-sourcing database and runtime — MIT licensed and free to use; see the Chronicle documentation for its own scope and setup.

Relationship to Components

Components is a React component library aligned with Arc application patterns. See the Components documentation for its packages and setup.

Applications may use Arc without Components and remain responsible for their own frontend, accessibility, browser, and design-system verification.

Start an Arc host

Arc's .NET packages embed this product-family README. The example below uses the Cratis.Arc package, Arc's ASP.NET Core integration; when viewing this README from a specialized package page, use that package's manifest and reference documentation for its own installation scope.

Use the .NET SDK declared by Arc's current global.json. Create an ASP.NET Core project and install the package:

dotnet new web -n MyApp
cd MyApp
dotnet add package Cratis.Arc

Replace Program.cs and run the host:

var builder = WebApplication.CreateBuilder(args);
builder.AddCratisArc();

var app = builder.Build();
app.UseCratisArc();
await app.RunAsync();

Starting the host confirms the basic Arc setup. For workers, consoles, or services without ASP.NET Core, the lightweight host is ArcApplication.CreateBuilder(args) from the separate Cratis.Arc.Core package; do not combine it with Cratis.Arc, whose ASP.NET Core services it does not register. See getting started with the lightweight host. Continue with the Arc documentation, and use GitHub Issues when the observed behavior does not match the documentation.

Packages and repository layout

SurfaceRole
Cratis.Arc / Cratis.Arc.Core.NET hosting, command/query pipelines, validation, identity, tenancy, HTTP, introspection, and application conventions
Cratis.Arc.ProxyGenerator.BuildBuild-time TypeScript proxy generation for recognized application artifacts
Cratis.Arc.MongoDB / Cratis.Arc.EntityFrameworkCore*Optional current-state persistence and observation adapters
Cratis.Arc.ChronicleOptional event-sourced command, projection, reducer, aggregate, reactor, tenancy, and compliance integration
Cratis.Arc.OpenApi / Cratis.Arc.SwaggerOptional OpenAPI document transformation for Arc concepts and endpoints
Cratis.Arc.Testing / Cratis.Arc.Chronicle.TestingCommand-scenario and optional Chronicle event/read-model testing helpers
@cratis/arcTypeScript command, query, validation, identity, and messaging runtime used by generated proxies
@cratis/arc.reactReact hooks, forms, dialogs, identity, messaging, and query composition for Arc contracts
@cratis/arc.react.mvvmOptional React/MVVM and dependency-injection integration
@cratis/arc.vite / @cratis/eslint-plugin-arcVite metadata/query helpers and Arc-specific frontend lint rules
Source/DotNET.NET framework source
Source/JavaScriptTypeScript and React package source
DocumentationProduct-owned documentation rendered on cratis.io
SamplesSample and integration applications used by repository checks

Package existence does not imply compatibility with every frontend, runtime, persistence provider, or product version. Check the package manifests and documentation for the versions you use.

Documentation map

Contributing

Arc is a framework-library repository. Changes to public APIs, analyzers, generated output, and package shapes can affect consumers and require the owning repository's compatibility and release review.

Repository development currently requires the SDK and toolchain versions declared by global.json and package.json. Follow the Cratis contribution guide and this repository's project context (AGENTS.md and the project rules it links) before changing public surfaces.

Before submitting documentation-only work, verify its links, anchors, and examples explicitly; current automated documentation checks are path-scoped. Source changes must pass the owning repository's applicable build, specification, TypeScript, and documentation gates.

  • .NET SDK 10.0.400+. Arc's analyzers and source generators are built against Roslyn 5.9.0, which ships with .NET SDK 10.0.400 and newer. On an older SDK band the compiler refuses to load them (CS9057), silently disabling proxy generation and the ARC*/ARCCHR* analyzers. Consuming the Cratis.Arc packages carries the same floor. Raising this floor is a minor version bump.
  • Node 23+
  • Yarn

Trim and NativeAOT diagnostics

Arc is not trim or NativeAOT compatible yet (#2204). Pull requests that change Source/DotNET run a ratchet that builds Cratis.Arc.Core, Cratis.Arc, Cratis.Arc.MongoDB, Cratis.Arc.EntityFrameworkCore and Cratis.Arc.Chronicle in one build with the trim and AOT analyzers on and compares the diagnostics per code, file and target framework with Source/DotNET/aot-baseline.json. It fails when a diagnostic or a trim/AOT suppression is added, and also when one is removed without shrinking the baseline. Run it locally with Python 3 and the .NET SDKs:

python3 scripts/aot-ratchet.py           # compare with the baseline
python3 scripts/aot-ratchet.py --update  # rewrite the baseline after fixing diagnostics, then commit it

Fix a new diagnostic by replacing the unsafe path rather than suppressing it. The analyzer ships with the .NET SDK, so run --update with the SDK global.json selects, as CI does; the baseline records the SDK version it was made with. When a new SDK changes what the analyzer reports, regenerate the baseline with --update in its own pull request. The normal build is unaffected; the analyzers only run when the script passes CratisAotAnalysis=true. A project is covered by importing Source/DotNET/AotAnalysis.props, which the script discovers, and the run fails unless every covered project reported for each of its target frameworks. The MongoDB, EF Core and Chronicle integrations are held at their current counts until they are annotated with [RequiresUnreferencedCode] and [RequiresDynamicCode].

Community and repository

PathDestination
Questions and discussionCratis Discord
Bugs and feature requestsGitHub Issues
ReleasesGitHub Releases
Documentationwww.cratis.io/arc
Blogblog.cratis.io
Security reportsPrivate security reporting
LicenseLICENSE

The Cratis ecosystem

Arc is part of Cratis — a platform for building event-sourced and CQRS applications.

Arc is MIT licensed and free to use. Other Cratis products have their own licensing and access terms.

Release notes and announcements: the Cratis blog.

版本与发布记录

@cratis/arc.vite 共发布 660 个版本,首次发布于 2025/11/30;过去 12 个月发布了 660 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
22.184.0latest2026/11/10今天
22.183.02026/11/10今天
22.182.12026/11/101 天前
22.182.02026/11/101 天前
22.180.02026/11/101 天前
22.179.02026/11/091 天前

关于 @cratis/arc.vite 的常见问题

@cratis/arc.vite 是什么?

Vite helpers for Cratis Arc applications — metadata and query plugins for the generated TypeScript proxies of the CQRS framework for ASP.NET Core.

如何安装 @cratis/arc.vite?

在项目目录运行 npm install @cratis/arc.vite,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vite(^6.0.0 || ^7.0.0 || ^8.0.0)、react(^18.0.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cratis/arc.vite 支持 TypeScript 吗?

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

@cratis/arc.vite 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@cratis/arc.vite 可以商用吗?

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

@cratis/arc.vite 的下载量有多少?

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

@cratis/arc.vite 还在维护吗?

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