Skip to content

netrondev/yew_crates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yew_crates

Opensource crates for working with rust and yew

yew_server_hook

A procedural macro that generates both server-side API handlers and client-side Yew hooks from a single function definition. Write your backend logic once, and automatically get both the Axum server endpoint and the Yew hook to call it.

Crates.io Documentation License

use yew_server_hook::yewserverhook;

#[yewserverhook(path = "/api/hello", method = "GET")]
pub async fn get_hello() -> Result<String, String> {
    Ok("Hello, World!".to_string())
}

yew_extra

Extract Axum request data within Yew server functions, similar to how leptos_axum provides extraction helpers for Leptos.

Crates.io Documentation License

Use the extract() function to access request data in your server functions:

use yew_extra::extract;
use axum::http::Method;
use axum_extra::extract::CookieJar;

#[yewserverhook(path = "/api/users")]
pub async fn get_users() -> Result<Vec<User>, AppError> {
    // Extract the HTTP method
    let method: Method = extract().await?;

    // Extract cookies
    let cookie_jar: CookieJar = extract().await?;

    // Use the extracted data
    if let Some(session) = cookie_jar.get("session_token") {
        // Validate session...
    }

    Ok(fetch_users().await?)
}

About

Opensource crates for working with rust and https://yew.rs/

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages