Expand description
The Next Rust runtime.
Most applications use this crate through the next-rust facade. It
contains the request pipeline (middleware → routing → pages/API routes/
server actions), server-side rendering with streaming, incremental static
regeneration, static files, the development endpoints and the hyper-based
production server.
Re-exports§
pub use actions::ActionContext;pub use actions::ActionRef;pub use actions::action_url;pub use app::ActionDef;pub use app::ApiDef;pub use app::App;pub use app::AppBuilder;pub use app::ErrorInfo;pub use app::PageBody;pub use app::PageDef;pub use app::Rendering;pub use app::Routes;pub use app::SegmentDef;pub use app::SlotDef;pub use app::parse_pattern;pub use context::Auth;pub use context::AuthUser;pub use context::CsrfToken;pub use context::Ctx;pub use context::Data;pub use context::Extension;pub use context::FormState;pub use context::FromContext;pub use context::Headers;pub use context::Nonce;pub use context::Path;pub use context::Query;pub use context::QueryMap;pub use context::RenderMode;pub use context::RequestContext;pub use context::RequestInfo;pub use context::ResponseHeaders;pub use cookies::Cookie;pub use cookies::Cookies;pub use cookies::SameSite;pub use embed::Embedded;pub use embed::EmbeddedFile;pub use error::Error;pub use error::ErrorKind;pub use error::OrNotFound;pub use error::Result;pub use error::not_found;pub use error::permanent_redirect;pub use error::redirect;pub use middleware::BoxFuture;pub use middleware::Cors;pub use middleware::Middleware;pub use middleware::Next;pub use middleware::RateLimit;pub use middleware::RequestId;pub use middleware::cors;pub use middleware::csrf;pub use middleware::protected;pub use middleware::rate_limit;pub use middleware::request_id;pub use middleware::security_headers;pub use request::Request;pub use response::Body;pub use response::Html;pub use response::IntoResponse;pub use response::Json;pub use response::Response;pub use runtime::run;pub use runtime::run_with;pub use seo::Robots;pub use seo::RobotsRule;pub use seo::Sitemap;pub use seo::SitemapEntry;pub use session::MemorySessionStore;pub use session::Session;pub use session::SessionStore;pub use session::sessions;pub use sse::SseEvent;pub use testing::TestClient;pub use testing::TestResponse;pub use bytes;pub use futures_util as futures;pub use http;pub use tokio;
Modules§
- actions
- Server actions:
#[server_action]functions exposed atPOST /_nr/action/<id>. - app
- Route definitions, application builder and request dispatch.
- context
- Render context and extractors.
- cookies
- Cookies with secure defaults.
- embed
- Files compiled into the production binary.
- error
- The error type used by pages, layouts, loaders, API routes and actions.
- export
- Static generation: renders static routes into a page cache.
- http_
date - IMF-fixdate formatting (RFC 9110 §5.6.7) without external dependencies.
- jobs
- Background and scheduled jobs.
- log
- Minimal structured logging.
- middleware
- Middleware.
- plugin
- Runtime plugins.
- request
- Incoming HTTP request.
- response
- Outgoing HTTP response.
- runtime
- Process entry point used by
next_rust::main!(). - seo
- Generated
sitemap.xmlandrobots.txt(app/sitemap.rs,app/robots.rs). - server
- Production HTTP server built on hyper.
- session
- Server-side sessions.
- sse
- Server-Sent Events.
- static_
files - Static file serving for
public/(and framework client files), from disk in development and from the binary in release builds. - testing
- In-process testing without a network socket.
Structs§
- CspNonce
- Per-request CSP nonce stored in request extensions.
Constants§
- CSRF_
COOKIE - Name of the CSRF double-submit cookie.
Functions§
- constant_
time_ eq - Constant-time byte comparison (for tokens).
- is_dev
- Whether the process runs in development mode (detailed errors).
- random_
hex nrandom bytes from the operating system CSPRNG, hex encoded.- revalidate_
path - Re-render
pathon its next request (pages rendered statically) and drop the matching data-cache entry. Usable from API routes and actions. - revalidate_
tag - Invalidate every cached page and data entry tagged with
tag.