| Crates.io | html_view |
| lib.rs | html_view |
| version | 0.1.0 |
| created_at | 2025-12-17 19:53:23.676067+00 |
| updated_at | 2025-12-17 19:53:23.676067+00 |
| description | A Rust library for rendering HTML content in a native tauri application. |
| homepage | |
| repository | https://github.com/jmg049/HTMLView |
| max_upload_size | |
| id | 1991044 |
| size | 55,926 |
The library component of the html_view suite of crates.
Allows the user to open up the viewer from within their application.
Render inline HTML with a single call:
use html_view;
fn main() -> Result<(), html_view::ViewerError> {
html_view::show("<h1>Hello, World!</h1>")?;
Ok(())
}
At runtime, html_view requires the viewer application binary.
Install it once:
cargo install html_view_app
This installs the viewer into ~/.cargo/bin.
If you want to use the viewer without writing Rust code:
cargo install html_view_cli
html_view::show("<h1>Hello!</h1><p>Simple HTML display</p>")?;
use html_view::ViewerOptions;
let mut options = ViewerOptions::inline_html("<h1>Custom Window</h1>");
options.window.width = Some(800);
options.window.height = Some(600);
options.window.title = Some("My App".to_string());
html_view::open(options)?;
use html_view::{ViewerOptions, ViewerWaitMode, ViewerResult};
let mut options = ViewerOptions::inline_html("<h1>Non-blocking</h1>");
options.wait = ViewerWaitMode::NonBlocking;
match html_view::open(options)? {
ViewerResult::NonBlocking(mut handle) => {
// Do other work here
let status = handle.wait()?;
println!("Viewer closed: {:?}", status.reason);
}
_ => unreachable!(),
}
ViewerOptions::local_file("index.html".into());
ViewerOptions::app_dir("./dist".into());
ViewerOptions::remote_url("https://example.com".parse()?);
Remote URLs require explicit permission, see Security below.
let mut options = ViewerOptions::inline_html("<h1>Auto-close</h1>");
options.environment.timeout_seconds = Some(5);
html_view::open(options)?;
By default:
To enable remote access:
let mut options = ViewerOptions::inline_html("<h1>Hello</h1>");
options.behaviour.allow_remote_content = true;
options.behaviour.allow_external_navigation = true;
options.behaviour.allowed_domains = Some(
vec!["example.com".to_string()]
);
This design prevents accidental network access or data leakage.
MIT
Contributions are welcome. See CONTRIBUTING.md.
Built using Tauri 2.0.