85 releases

new 0.7.3 Jan 4, 2025
0.7.2 Dec 21, 2024
0.7.0 Nov 30, 2024
0.7.0-preview2 Apr 29, 2024
0.0.3 Nov 27, 2022

#1803 in Web programming

Download history 8477/week @ 2024-09-20 9249/week @ 2024-09-27 8629/week @ 2024-10-04 9288/week @ 2024-10-11 10183/week @ 2024-10-18 8959/week @ 2024-10-25 10408/week @ 2024-11-01 7299/week @ 2024-11-08 8286/week @ 2024-11-15 7054/week @ 2024-11-22 9985/week @ 2024-11-29 10893/week @ 2024-12-06 12182/week @ 2024-12-13 6807/week @ 2024-12-20 5373/week @ 2024-12-27 9789/week @ 2025-01-03

36,273 downloads per month
Used in 40 crates (32 directly)

MIT license

215KB
4K SLoC

Leptos Meta

Leptos Meta allows you to modify content in a document’s <head> from within components using the Leptos web framework.

Document metadata is updated automatically when running in the browser. For server-side rendering, after the component tree is rendered to HTML, ServerMetaContextOutput::inject_meta_context will inject meta tags into a stream of HTML inside the <head>.

use leptos::prelude::*;
use leptos_meta::*;

#[component]
fn MyApp() -> impl IntoView {
    // Provides a [`MetaContext`], if there is not already one provided.
    provide_meta_context();

    let (name, set_name) = create_signal("Alice".to_string());

    view! {
      <Title
        // reactively sets document.title when `name` changes
        text=move || name.get()
        // applies the `formatter` function to the `text` value
        formatter=|text| format!("{text}” is your name")
      />
      <main>
        <input
          prop:value=move || name.get()
          on:input=move |ev| set_name.set(event_target_value(&ev))
        />
      </main>
    }
}

Feature Flags

  • ssr Server-side rendering: Generate an HTML string (typically on the server)
  • tracing Adds integration with the tracing crate.

Important Note: If you’re using server-side rendering, you should enable ssr.

Dependencies

~21–34MB
~517K SLoC