Expand description
Shared runtime for the Krab full-stack web framework.
The crate root holds the view tree that view! builds and SSR renders —
Node, Element, Attribute, EventListener, the Render and
IntoNode traits — and the hydration markers that let the browser
runtime (krab_client) match server-rendered HTML back to it. The modules
cover the rest of a service: configuration and secret sourcing
(config), the HTTP stack, database and migration governance, the
shared store, telemetry, resilience, signals, render policy, ISR, i18n,
WebSockets and server functions.
§Features
There are no default features; much of the crate is behind one:
| Feature | Enables |
|---|---|
rest | The axum HTTP stack: http and its auth, errors, headers, runtime and security modules; server functions |
graphql | graphql, on async-graphql |
grpc-semantics | grpc_semantics: gRPC status codes and grpc-timeout parsing for a gateway — not a gRPC transport |
auth | credentials: Argon2id password hashing |
db-postgres | db with the Postgres runtime and migration governance |
db-sqlite | db driver selection with the SQLite driver |
redis-store | The Redis-backed shared store |
web | Browser bindings for the wasm32 island runtime |
Node is !Send (its Dynamic variant holds an Rc): build and render
it inside synchronous code, and do not hold one across an .await.
Modules§
- action
- Client-initiated async writes with observable state.
- config
- Environment-driven configuration and the secrets-source policy.
- control_
flow - Runtime behind
view!’s built-in control-flow tags. - credentials
- Password credential verification.
- csrf
- CSRF wire-contract names shared by the server-side protection middleware
and the wasm client half of
#[server]. - db
- Database support: driver selection, and the Postgres migration-governance runtime.
- error_
boundary - Render-time error boundary.
- graphql
- GraphQL execution with framework policy guards (feature
graphql), on top ofasync-graphql. - grpc_
semantics - gRPC semantics for a gateway — not a gRPC transport.
- head
- Head Management
- http
- The HTTP surface of
krab_core(featurerest), in one import path. - http_
auth - Request authentication and authorisation for the
restHTTP stack. - http_
error - The JSON error envelope every Krab HTTP surface answers with.
- http_
headers - Response-header middleware: the fixed security-header set and CORS.
- http_
runtime - Per-service HTTP runtime state and the health, readiness and metrics handlers that report on it.
- http_
security - Client-IP extraction and CSRF protection for the HTTP stack.
- i18n
- Internationalization (i18n)
- image
Deprecated <picture>markup with AVIF/WebP<source>s.- isr
- Incremental Static Regeneration (ISR)
- layout
- Layout System
- protocol
- Protocol selection: which API protocols (REST, GraphQL, RPC) a service exposes, how they are deployed, and which one a request is served with.
- render_
policy - A per-route declaration of how a page is rendered, cached, placed and delivered.
- render_
stream - Streaming SSR: progressive
<Suspense>streaming, suspense-boundary markers, and the byte-budgeted chunk writer. - repository
- A driver-neutral user-lookup port (features
db-postgresordb-sqlite). - resilience
- Circuit breaker primitives for outbound resilience.
- resource
- Client-driven async reads with observable state.
- server_
fn - Server Functions (
#[server]) - service
- Service bootstrap: a bind configuration and, with feature
rest, an axum server loop that shuts down gracefully on SIGINT or SIGTERM. - service_
contract - Transport-agnostic service contracts, so one service can call another either in-process or over the network without the caller changing.
- signal
- Krab reactive signal system.
- static_
assets - Serving static assets safely.
- store
- A small key-value store abstraction for state that must be shared between a service’s replicas: rate-limit and auth-failure counters, token revocations, ISR cache entries and render leases.
- style_
scope - Component-scoped CSS class rewriting.
- suspense
- Runtime behind
view!’s<Suspense>tag. - telemetry
- Structured-logging setup: JSON
tracingoutput and the canonicalservice_startedevent. - ws
- WebSocket Ergonomic Layer
Macros§
- collect_
server_ fns - Collect server function registrations into an array.
Structs§
- Attribute
- A
name="value"attribute of anElement. - Element
- An HTML element in the view tree.
- Event
Listener - An event handler attached to an
Element(on:click={...}inview!). Only meaningful in the browser. - Hydration
Node Marker - Identifies one element inside a hydration boundary, so the browser can match server-rendered markup to the view tree it rebuilds.
Enums§
- Node
- A node in the view tree that
view!builds.
Constants§
- HYDRATION_
NODE_ ID_ ATTR - Attribute that carries an element’s
HydrationNodeMarkerin rendered HTML:data-krab-node-id="{boundary_id}/{path}".
Traits§
- Into
Attribute Value - Conversion of a reactive attribute source’s result into an attribute value;
Nonemeans the attribute is absent. SeeAttribute::dynamic. - Into
Node - Conversion into a
Node; how expressions interpolated with{...}inview!become part of the tree. - Render
- Conversion to an HTML string.
Functions§
- annotate_
hydration_ tree - Stamps a
HydrationNodeMarkeron every element ofnodefor the boundaryboundary_id, starting from the root marker. - next_
hydration_ boundary_ id - A fresh boundary id,
{scope}:{n}, withnfrom a process-wide counter. The#[island]macro calls it once per rendered island, with the island’s name asscope, so ids are unique within a process but not across processes or restarts.
Type Aliases§
- Dynamic
Attribute Value - The source of a reactive attribute: called on the server at render time and
in the browser inside an effect, each time the signals it reads change.
Nonemeans “attribute absent”. SeeAttribute::dynamic.