Installations
npm install tauri-plugin-system-info-api
Developer Guide
Typescript
Yes
Module System
ESM
Node Version
22.4.1
NPM Version
10.8.1
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
Rust (54.73%)
JavaScript (31.08%)
TypeScript (14.19%)
Developer
HuakunShen
Download Statistics
Total Downloads
20,917
Last Day
25
Last Week
845
Last Month
4,999
Last Year
19,937
GitHub Statistics
37 Stars
57 Commits
4 Forks
1 Watching
5 Branches
1 Contributors
Bundle Size
10.08 kB
Minified
3.09 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.0.8
Package Id
tauri-plugin-system-info-api@2.0.8
Unpacked Size
58.78 kB
Size
9.30 kB
File Count
14
NPM Version
10.8.1
Node Version
22.4.1
Publised On
17 Oct 2024
Total Downloads
Cumulative downloads
Total Downloads
20,917
Last day
-85.1%
25
Compared to previous day
Last week
-41.8%
845
Compared to previous week
Last month
360.7%
4,999
Compared to previous month
Last year
1,934.4%
19,937
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
5
Tauri Plugin system-info
TypeScript Documentation: https://huakunshen.github.io/tauri-plugin-system-info Rust Documentation: https://docs.rs/crate/tauri-plugin-system-info
This is a Tauri plugin for reading system information.
- Rust Crate: https://crates.io/crates/tauri-plugin-system-info
- TypeScript API: https://www.npmjs.com/package/tauri-plugin-system-info-api
Installation
If you are installing from npm and crates.io package registry, make sure the versions for both packages are the same, otherwise, the API may not match.
For Tauri v1 app, use version 1.x, for Tauri v2 app, use version 2.x. (this applies to both npm and crates.io packages)
Rust Install
cargo add tauri-plugin-system-info
within src-tauri
to add the package.
Or add the following to your Cargo.toml
for the latest unpublished version (not recommanded).
1tauri-plugin-system-info = { git = "https://github.com/HuakunShen/tauri-plugin-system-info", branch = "v1" } # use v2 branch for Tauri v2 plugin
NPM Install
Run the following to install JavaScript/TypeScript API package.
1npm i tauri-plugin-system-info-api 2# npm add https://github.com/HuakunShen/tauri-plugin-system-info # or this for latest unpublished version (not recommended)
In main.rs
, add the following to your tauri::Builder
:
1fn main() { 2 tauri::Builder::default() 3 .plugin(tauri_plugin_system_info::init()) 4 .run(tauri::generate_context!()) 5 .expect("error while running tauri application"); 6}
Info Supported
- CPU
- Network
- Process
- Memory
- Hostname
- Kernel Version
- OS Version
- Battery
Third Party Libraries Used
API
TypeScript
All TypeScript APIs can be found in api.ts.
Return type of each API is added. The object structures can be found in type.ts.
Valibot was used to define type schema and infer TypeScript types. You can import the types exported from the npm package.
The exported Valibot schemas can be used to parse data and make sure the data returned from rust APIs match the desired structure defined in schema.
1import { 2 allSysInfo, 3 memoryInfo, 4 staticInfo, 5 cpuInfo, 6 AllSystemInfo, 7 StaticInfo, 8 MemoryInfo, 9 CpuInfo, 10 batteries, 11 Batteries, 12} from "tauri-plugin-system-info-api"; 13 14console.log(AllSystemInfo.parse(await allSysInfo())); 15console.log(MemoryInfo.parse(await memoryInfo())); 16console.log(StaticInfo.parse(await staticInfo())); 17console.log(CpuInfo.parse(await cpuInfo())); 18console.log(Batteries.parse(await batteries()));
Rust
The API functions in Rust are all exported, so that you can also build your own commands.
Here is a simple example:
1use tauri_plugin_system_info::utils::{SysInfo, SysInfoState}; 2use tauri_plugin_system_info::commands; 3use tauri_plugin_system_info::model::Cpu; 4 5#[tauri::command] 6fn cpu_count() -> Result<usize, String> { 7 let state = SysInfoState::default(); 8 let sysinfo = state.sysinfo.lock().unwrap(); 9 let cpu_count = sysinfo.cpu_count(); 10 Ok(cpu_count) 11}
See https://docs.rs/crate/tauri-plugin-system-info/ for full rust documentation.
SysInfo
is the API struct that can be used to access all information. It's like a wrapper for sysinfo
APIs and other crates. The reason for doing this is, some structs in third party libraries cannot be cloned or serialized, and thus cannot be sent to the frontend.
I aggregate all the APIs, do structure conversion and serilization with custom code.
Usage
See SvelteKit Example for an example written with SvelteKit.
No vulnerabilities found.
No security vulnerabilities found.