Trait leptos_server::ServerFn
source · pub trait ServerFn: ServerFn<Scope> {
// Provided method
fn register() -> Result<(), ServerFnError> { ... }
}
Expand description
Defines a “server function.” A server function can be called from the server or the client,
but the body of its code will only be run on the server, i.e., if a crate feature ssr
is enabled.
(This follows the same convention as the Leptos framework’s distinction between ssr
for server-side rendering,
and csr
and hydrate
for client-side rendering and hydration, respectively.)
Server functions are created using the server
macro.
The function should be registered by calling ServerFn::register()
. The set of server functions
can be queried on the server for routing purposes by calling server_fn_by_path.
Technically, the trait is implemented on a type that describes the server function’s arguments.
Provided Methods§
sourcefn register() -> Result<(), ServerFnError>
fn register() -> Result<(), ServerFnError>
Registers the server function, allowing the server to query it by URL.