corten

mcp
Guvenlik Denetimi
Uyari
Health Uyari
  • License — License: MIT
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Low visibility — Only 6 GitHub stars
Code Gecti
  • Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Gecti
  • Permissions — No dangerous permissions requested

Bu listing icin henuz AI raporu yok.

SUMMARY

Fast web apps: Rust renders every page on the server, plain JavaScript does the rest in the browser. Typed end to end, live data over server-sent events, and one server for web, native and agent clients.

README.md

Corten

Fast web apps: Rust on the server, plain JavaScript in the browser, and each doing the work it is fastest at.

CI
License: MIT
Rust 1.89+

Getting started |
Guides |
Examples |
Performance |
Changelog

Corten is a Rust web framework for apps where speed at the user's end matters. The server
renders every page as finished HTML with html!, a JSX-like macro. In the browser, plain
JavaScript next to each component does what the page can do with the data it already has, with
no request. When the server is needed, a small runtime swaps pages and patches part of one, and
live data streams in over server-sent events. One handler answers the browser, native apps and
AI agents.

Visit corten.run for a page that demonstrates Corten.

Highlights

  • HTML that works on its own. Every page arrives rendered. Links are links and forms post,
    so a page works before its scripts load, and without them.
  • Plain JavaScript where it is fastest. Behavior is a function in a script next to its
    component, called from the markup by name. No WASM, no virtual DOM, no hydration.
    A 15.8 KB (gzip) runtime.
  • Partial updates from the same handler. A form marked data-patch gets back only the
    elements that changed; without JavaScript the same handler answers with the whole page.
  • Live data. <corten-live> fragments and keyed feeds stream numbered patches over
    server-sent events, with replay and resume, and one feed can run across several instances.
  • Typed end to end. Routes, form fields, element ids, CSS classes, handler calls, events and
    messages are Rust types, and the TypeScript types for scripts are generated from Rust. A typo
    at these seams fails the build, corten check or startup, before any request.
  • One server, every surface. The same handler answers a browser with HTML, a native app
    with JSON, and an AI agent as a Model Context Protocol tool.
  • Production defaults. A strict CSP, a cross-site write check, error pages, versioned
    assets, cache headers that never share one user's page with another, compression, health
    checks, graceful shutdown and an installable PWA, from corten::serve(App::new(routes)).
    Apps with live streams also need an HTTP/2 proxy or CDN in front
    (Deploying), even when the app ends TLS itself.
  • One binary. No JavaScript build step or bundler in the app; static/ is compiled into the
    program.

Quick start

cargo install corten-cli    # or cargo binstall corten-cli, for the prebuilt binary
npm install --global typescript    # needs Node.js; corten check needs TypeScript 6.0 or later
corten new my-app
cd my-app
corten dev    # serves http://localhost:3000 and reloads on save

cargo binstall checks the prebuilt binary's download only by HTTPS; to check it against its
build first, download it as in
Verify a prebuilt binary, using GitHub
artifact attestations and SHA256SUMS. Corten keeps no minisign signing key
(Choice 49).

corten new writes a working app: a page, a form that patches part of the page, a component
with a script, a test and a Dockerfile. Getting started walks
through it.

Example

A page with a form. With JavaScript, submitting it swaps in the greeting; without JavaScript it
posts and the whole page comes back, at the page's own address. One handler serves both.

use corten::prelude::*;

// Every URL, typed, with the handler for each method. A route without one does not compile.
// The form posts back to its page, so the page and its form share one address.
#[corten::routes]
mod url {
    #[route("/", get = home, post = greet)]
    pub struct Home;
}

#[tokio::main]
async fn main() -> std::io::Result<()> {
    let app = App::new(url::router());
    corten::serve(app).await
}

// The return type is what the route answers: a page, a patch or a redirect, and on failure the
// app's error page. `JsonResult<T>` answers JSON, failures included.
async fn home(req: Req) -> HtmlResult {
    req.page(home_page(&req, ""))
}

async fn greet(req: Req, Form(form): Form<GreetForm>) -> HtmlResult {
    // With JavaScript, only the greeting, swapped in by its id; without, the whole page.
    req.patch_or(Greeting { name: &form.name }, || async { req.page(home_page(&req, &form.name)) }).await
}

#[derive(Fields)]
struct GreetForm {
    name: String,
}

fn home_page(req: &Req, name: &str) -> impl Document {
    let f = GreetForm::FIELDS;
    html! {
        <Layout req={req} title="Welcome">
            <h1>"Welcome"</h1>
            <form method="post" action={url::Home} data-patch>
                <input name={f.name} required>
                <button>"Greet me"</button>
            </form>
            <Greeting name={name} />
        </Layout>
    }
}

/// The whole document, a component like any other: `corten new` writes one for you to change.
/// A client navigation gets only the `<title>` and `<main>`'s children.
#[component]
fn Layout(req: &Req, title: &str, children: impl Render) -> impl Document {
    html! {
        <!DOCTYPE html>
        <html lang={req.lang()}>
            <head>
                <title>{title}</title>
                <Corten />
            </head>
            <body>
                <main>{children}</main>
            </body>
        </html>
    }
}

/// The greeting's id, a type: the page and the patch name the element the same way.
#[derive(Id)]
struct GreetingId;

/// Rendered by the page and by the patch, so the two cannot drift.
#[component]
fn Greeting(name: &str) -> impl Patch {
    html! {
        <p id={GreetingId} aria-live="polite">
            if !name.is_empty() {
                "Hello, " {name} "!"
            }
        </p>
    }
}

A misspelled route, field, prop or id does not compile, and neither does a route without a
handler, a patch with a top-level element the browser would drop (one without an id), or a
document without its <title>, <Corten /> (where the runtime and the page's scripts go) or
<main>. Behavior lives in a script next to the component: plain functions the
markup calls with the elements they use.

// src/click_counter.rs
#[component(js)]
pub fn ClickCounter() -> impl Render {
    let total = refs();
    html! {
        // A click calls count() in click_counter.js with the <output>.
        <button type="button" on:click={js::count(total)}>
            "Clicks: "
            <output ref={total}>"0"</output>
        </button>
    }
}
// src/click_counter.js
/** @param {HTMLOutputElement} total */
export function count(total) {
  total.value = String(Number(total.value) + 1);
}

js::count exists because the script exports count, and it takes total because the JSDoc
says an HTMLOutputElement and the ref is on an <output>. Either mismatch is a compile error.

How it works

  1. The server renders. Each route is a typed struct with its handler. The handler returns
    a page, a patch or a redirect, written with html! and components
    (Views, Requests and forms).
  2. The browser acts on what it has. Sorting, filtering, selecting, totals and editing run
    in plain JavaScript functions next to their components; views are typed classes over the
    rows the server rendered, so taking over a page reads it instead of rebuilding it
    (Scripts).
  3. The runtime fills the gaps. Links swap the page's content, forms patch the elements
    that changed, and AbortSignal cancels work in the browser and on the server alike
    (Cancellation).
  4. Live data is patches. <corten-live> redraws a fragment and feeds keep keyed rows in
    step, both over server-sent events that resume where they left off
    (Live data).
  5. Every client uses the same routes. A screen answers a request for JSON with its data,
    actions are the same POSTs, and corten-protocol gives native and agent clients the feed
    (Surfaces).

Performance

Historical round r20 is the first validated v2 production baseline, measured on 2026-11-12 (UTC)
at 43550265076e378d2159a9ebc254cf9412a2355a on one dedicated c-8 (Intel(R) Xeon(R) Platinum 8280 CPU @ 2.70GHz).
It is a saved measurement of that commit, not today's code or a baseline for the newer
workload-group campaign. There is no speed delta from r16, catalog c1/c2 or another workload.

Group production, feature profile marketplace-production/v1, native
PROFILE=matched, connection cap 1000. Corten and ASP.NET Core qualified in both sources
and passed every browser/content gate. Next.js, FastAPI, Express, Topcoat, Leptos were
probed and excluded, not timed. The report preserves each missing requirement and lists all
omitted adapters, which were not tested. These are measured adapter configurations, not claims
about what their frameworks could implement. Conditional GET/ETag and downstream readiness
are disclosed exceptions; logging remains native, not normalized.

The table is Corten's median [min-max] of 3 passes. Pages format values per request;
the other page locales and both admitted adapters are in the
full results and raw report.

Profile, 64 users Corten req/s p95 ms Counted CPU us/request
Localized page from memory, en-US 20,544.98 [19,501.83-21,843.88] 8.12 [7.36-8.34] 41.58 [39.27-43.30]
Locale-neutral JSON from memory 22,218.09 [21,286.85-23,037.44] 7.76 [7.62-8.30] 30.92 [28.56-35.06]
Localized page from HTTP, en-US 6,696.24 [6,220.59-7,233.94] 13.29 [13.21-13.72] 149.18 [138.00-160.59]
Locale-neutral JSON from HTTP 8,465.41 [7,546.34-8,486.89] 11.43 [11.07-12.47] 117.74 [117.42-131.97]

At fixed 150 en-US memory pages/s, Corten used 3.38 [2.41-3.48]% of one core
and 11.39 [11.25-11.41] MiB steady memory (11.64 [11.60-11.65] MiB sampled peak).
Container start to first complete en-US memory page was 182.00 [176.00-183.00] ms,
before readiness/warmup, not process-exec or browser-interactive time.

Warmup is 10s and each phase 15s, with identity encoding. Closed-loop throughput is
observed, not proven maximum capacity: Corten's memory-source app CPU is below 95% in some
closed-loop passes. No measured HTTP phase reached 80% upstream CPU; the highest phase average was 74.89% of one core.
Full pass-specific limits stay
beside the detailed tables. No request failures, dropped fixed-rate iterations or app stops
were recorded. Short-window ranges are not confidence intervals or an overall speed ranking.

Historical Measurements

The following table preserves earlier measurements, including the site's measurement
certificate references. Its first five rows are the old marketplace implementation from
r16, not v2: requests were uncompressed and untagged, and localization work differed
between frameworks. They establish neither a fair framework ranking nor a comparison
with r20. Browser, bytes and build measurements remain
historical. The final row is the separate
client-heavy round browser-4 (2026-11-11, at
3fb4b1ac, on a Xeon Platinum 8358), not the marketplace workload:

What Corten, measured
Item pages rendered from memory 20,705 a second, 47 µs of CPU each
The same item as JSON 26,385 a second
Memory after the first request 1.3 MiB
JavaScript the item page loaded 14.1 KB (gzip)
Interactive on a throttled phone, on desktop 468 ms, 59 ms
Taking over 1,000 server-rendered rows 10.2 ms, 101 bytes of memory per row

See Performance and the nightly procedure
for scope, methodology and limits. Framework capabilities remain separate in
Highlights, not inferred from benchmark speed.

When to use it

Corten fits apps where speed at the user's end matters: stores, marketplaces, dashboards, admin
tools, rich editing screens, content with live parts. The server owns the data and decides what
a write does; the browser does everything it can with the data it already has. It suits teams
that want Rust on the server and the platform's own JavaScript in the browser, with types across
the seam between them.

Look elsewhere for an offline-first app whose data lives on the device (Corten's offline support
is a fallback page and cached files), for server-side TSX or React components, or for a pure
static site (a static site generator is simpler).

Documentation

Guide What it covers
Getting started the corten command and the parts of an app
Views html!, components, typed links and messages
Requests and forms request modes, patches, validation, redirects
Scripts behavior in the browser: handlers, refs, typed events, views
Styles a scoped CSS file per component, design tokens, themes
Live data <corten-live>, feeds, running a feed across instances
Cancellation AbortSignal in the browser and on the server, deadlines
Type safety every seam between server and client, and how it is checked
The app every default App puts around your routes, and how to replace each
Headless components corten-ui: number field, combobox, tabs, menu button, toaster, copy button, relative time, checkbox group, required-when
The UI kit corten ui: theme tokens and styled components copied into the app as source
Deploying behind a proxy or CDN: what it must do, an nginx configuration, cache settings for Cloudflare and CloudFront; the release profile and what it costs; a profile-guided build and what it gained
Surfaces one server for web, native apps and agents
Design decisions and limits why it is built this way, and what it does not do
Performance every benchmark table, against seventeen other apps and five client frameworks

API reference: cargo doc --open -p corten-run. Building an app with an AI agent? The
corten skill gives it the rules and recipes.

Examples

In the order to read them; each README says how to run it and where each piece is.

  1. watchlist: start here. A stock watchlist with live prices, news, price
    alerts and an account; each route shows one piece of Corten.
  2. card-market: a card store with every production module on (security,
    PWA, i18n, caching, JSON routes for partners and agents). Read it before you deploy.
  3. seller-desk: a client-heavy inventory screen, for a screen that does
    more in the browser than forms and links.
  4. deck-builder: drag and drop and keyboard moves, undo and redo, a
    chart drawn in the browser, and autosave that rolls back a change the server refuses. Read it
    when a screen keeps state in the browser and saves it as the user works.
  5. auction-room: a live auction where signed-in people bid on the same
    lots at once, with SQLite, per-bidder notices and rate limits. Read it when several people
    act on shared data in real time.
  6. ui-gallery: every corten-ui component and every UI kit component.
  7. listings-feed: one live feed served by several instances through
    Postgres and NATS, for when one instance is not enough, with a failover benchmark that kills
    instances while browsers follow.
  8. corten-site: Corten's own site, one page that demonstrates itself,
    with the files that deploy it to one small machine. Read it for a page of content rather than
    an app, and for a deploy without a container.

Crates

Crate What it is
corten-run the framework, on hyper, whose library is corten: App, Req, html!, handlers, the browser runtime
corten-cli the corten command: new, dev, check, build
corten-macros the macros, on proc_macro alone (no syn)
corten-ui optional headless components for widgets the browser lacks
corten-feed live feeds: rows, numbered patches, replay, resume
corten-cluster one feed across instances: Postgres outbox, NATS JetStream
corten-protocol the feed wire format and a client replica, for native and agent clients

Status

Corten is 0.2: usable and tested, on Rust 1.89 or later, and built for
Chase Sets. The API will change before 1.0; CHANGELOG.md
lists what changed. A release publishes every crate at one version on crates.io and attaches a
prebuilt corten for Linux, macOS and Windows to the GitHub release. The framework's package is
corten-run (corten on crates.io is someone else's) and its library is corten, so an app
depends on corten = { package = "corten-run", version = ".." } (corten new writes it) and its
code writes use corten::.... The runtime and corten-ui are tested in Chromium, Firefox and
WebKit. corten::serve speaks HTTP/1.1, so an app with live streams goes behind a proxy or CDN
that serves browsers HTTP/2 or HTTP/3 (Deploying).

Values

  1. Fast, and proven fast. Speed at the user's end is the goal, and every claim has a measured
    number behind it. The work goes where it is fastest for the user: the server renders the first
    page and anything that needs its data, and the browser does what it can with what it already
    has. A server render that is slower than a client action is the wrong choice. A change to
    rendering, the runtime or the request path is measured before and after with the number that
    can see it: instructions per request, time, or bytes shipped
    (CONTRIBUTING.md). We say no to features that cost
    every user to help a few, like view transitions on every swap.
  2. Standards first, extended rather than replaced. Use what the browser, HTTP and the web's
    other standards already provide: custom elements, FormData, AbortSignal, the Navigation
    API, popover, server-sent events, native validation, Problem Details, CLDR. Where Corten needs
    more, it builds on the standard (a custom element, an Event subclass, a data- attribute)
    rather than adding a concept of its own. Corten uses a custom element where the behavior is
    the element's own (<corten-live> holds a live connection); a component's behavior is a
    handler on whatever element fits, since a table row cannot be a custom element in every
    browser (design Choice 17). Build only what the platform lacks, and
    remove it once the platform catches up. One idea should work the same everywhere, so
    cancellation is AbortSignal in the browser and on the server.
  3. HTML that works on its own. Every page's first render comes from the server, and links and
    forms work without JavaScript. Scripts make a page faster and richer but never hold it up. A
    feature only a browser can provide (drag and drop, a canvas) needs JavaScript, and the page
    around it still works.
  4. Mistakes fail at compile time. No strings at the seams between server and client: routes,
    handler calls, refs, class names, form fields and messages are all typed. TypeScript types are
    generated from Rust, never written by hand. The app's own setup is held to the same bar: a
    route outside its area, a signed-in route whose handler does not take the caller, a public
    (cacheable) answer whose handler reads who is asking, a handler that hides what its route
    answers, or a prefix with a parameter does not build, and no route reaches the app another
    way. Where the compiler cannot see a mistake, it fails at startup, and only what depends
    on the request is checked per request. If a guarantee exists, a test proves it fails to
    compile when broken.
  5. One way to do each thing. Behavior is a function the markup calls, cleanup has one hook,
    and a request handler serves every mode. Fewer concepts make large codebases readable for
    people and for agents. The behavior sits next to its markup, and each call names everything
    the function touches.
  6. Small surface, deliberate dependencies. A dependency or a new concept has to clearly earn
    its place. The framework owns what nearly every app needs, like security headers,
    cancellation, error pages and assets. Domain logic and things only some apps use belong to the
    app or platform.
  7. Good defaults, easy overrides. corten::serve(App::new(routes)) should be production-ready.
    Every default can be replaced in one line, and the common case stays short.
  8. One server, every surface. The same handler and data serve the browser, native apps and AI
    agents. The server is the source of truth for the data and for what a write does; the state
    of a screen (a sort, a selection, an open panel) belongs to the client showing it.
  9. Verified, not assumed. Every runtime behavior has a browser smoke test. Reliability work,
    like failover and lost-patch counts, is benchmarked rather than argued.

When two values conflict, this order decides:

  1. Correctness and reliability. Following a standard where one fits is part of being correct:
    a header or format of Corten's own in its place needs a recorded reason
    (design rule 10), and typing wraps a standard rather than replacing it.
  2. Performance at the user's end.
  3. Compile-time safety and one way to do things: a mistake the compiler can catch is a compile
    error, not a startup panic or a per-request check (design rules).
  4. Developer convenience.

So the deadline timer that cost 640 ns per request was reworked rather than kept for
convenience, and a nicer API that slows every page loses. Every pull request is reviewed against
these values, in this order, before it merges (CONTRIBUTING.md).

Contributing

Issues and pull requests are welcome. CONTRIBUTING.md has the layout, the
checks and how a change is reviewed; report security issues as SECURITY.md
describes.

License

MIT. The kit's icons (crates/corten-cli/kit/icon.rs, which corten ui add icon copies
into an app) are Lucide's, under its ISC license and, for those derived from
Feather, Feather's MIT license; both are in that file.

Name

Cor-ten is weathering steel: it is meant to rust, and the rust layer is what protects it. Rust
underneath, a thin protective surface on top. "COR-TEN" is a U.S. Steel trademark for steel.

Yorumlar (0)

Sonuc bulunamadi