leptos_hl_contact/lib.rs
1//! # leptos-hl-contact
2//!
3//! A reusable, secure contact form plugin for [Leptos](https://leptos.dev) v0.8.
4//!
5//! ## Architecture
6//!
7//! ```text
8//! ┌──────────────────────────────────────────┐
9//! │ UI Component (ContactForm) │ client + server
10//! ├──────────────────────────────────────────┤
11//! │ Server Function (submit_contact) │ server only
12//! ├──────────────────────────────────────────┤
13//! │ Delivery Backend (ContactDelivery) │ server only
14//! └──────────────────────────────────────────┘
15//! ```
16//!
17//! ## Feature flags
18//!
19//! | Flag | Effect |
20//! |----------------|-------------------------------------------------|
21//! | `hydrate` | Enables Leptos hydration for the client side. |
22//! | `ssr` | Enables server-side rendering and server fns. |
23//! | `islands` | Enables Leptos Islands architecture. |
24//! | `smtp-lettre` | Enables the SMTP delivery adapter. |
25//! | `axum-helpers` | Enables Axum-specific integration helpers. |
26//!
27//! ## Quick start
28//!
29//! See the
30//! [`examples/axum-basic`](https://github.com/nabbisen/leptos-hl-contact/tree/main/examples/axum-basic)
31//! directory for a complete working example.
32//!
33//! ## Security
34//!
35//! SMTP credentials and the recipient address live **only on the server**.
36//! They are never serialised to WASM or returned to the client.
37//! See the [security documentation](https://github.com/nabbisen/leptos-hl-contact/blob/main/docs/src/security.md).
38
39pub mod config;
40pub mod delivery;
41pub mod error;
42pub mod model;
43pub mod security;
44
45// UI components — compiled for both SSR and hydrate targets.
46pub mod components;
47
48// Server function — compiled only when `ssr` is active.
49pub mod server;
50
51// CSRF token helper — compiled only when `csrf` is active.
52#[cfg(feature = "csrf")]
53pub mod csrf;
54
55// Axum integration helpers — compiled only when `axum-helpers` is active.
56#[cfg(feature = "axum-helpers")]
57pub mod axum_helpers;
58
59// ---------------------------------------------------------------------------
60// Re-exports
61// ---------------------------------------------------------------------------
62
63pub use components::ContactForm;
64pub use config::{ContactFormClasses, ContactFormLabels, ContactFormOptions, ContactServerPolicy};
65pub use delivery::{ContactDelivery, ContactDeliveryContext};
66pub use error::{ContactDeliveryError, ContactFieldErrors, ContactValidationError};
67pub use model::ContactInput;
68pub use server::submit_contact;
69
70#[cfg(feature = "csrf")]
71pub use csrf::{CsrfConfig, CsrfConfigContext, CsrfToken, generate_csrf_token, verify_csrf_token};