Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ctron/yew-consent

Managing consent with Yew
https://github.com/ctron/yew-consent

Last synced: 4 days ago
JSON representation

Managing consent with Yew

Awesome Lists containing this project

README

        

# yew-consent

[![crates.io](https://img.shields.io/crates/v/yew-consent.svg)](https://crates.io/crates/yew-consent)
[![docs.rs](https://docs.rs/yew-consent/badge.svg)](https://docs.rs/yew-consent)

> Managing user consent with Yew

## Usage

Add it to your project:

```shell
cargo add yew-consent
```

Then, add it your application component:

```rust
#[function_component(Application)]
fn application() -> Html {
let ask = use_callback((), |context, ()| html!());

html!(
{ask}>

>
)
}
```

And then, you can check consent later:

```rust
#[function_component(State)]
fn state() -> Html {
let consent = use_consent::<()>();

html!(
<>


{"Consent state"}

{ format!("{consent:#?}")}


>
)
}
```

Also see the example here: [example](example).

You can run the example using:

```shell
cd example
trunk serve
```