@@ -70,7 +70,42 @@ fn main() {
7070Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
7171
7272``` javascript
73+ import { openUrl , openPath , revealItemInDir } from ' @tauri-apps/plugin-opener'
7374
75+ // Opens the URL in the default browser
76+ await openUrl (' https://example.com' )
77+ // Or with a specific browser/app
78+ await openUrl (' https://example.com' , ' firefox' )
79+
80+ // Opens the path with the system's default app
81+ await openPath (' /path/to/file' )
82+ // Or with a specific app
83+ await openPath (' /path/to/file' , ' firefox' )
84+
85+ // Reveal a path with the system's default explorer
86+ await revealItemInDir (' /path/to/file' )
87+ ```
88+
89+ ### Usage from Rust
90+
91+ You can also use those APIs from Rust:
92+
93+ ``` rust
94+ use tauri_plugin_opener :: OpenerExt ;
95+
96+ fn main () {
97+ tauri :: Builder :: default ()
98+ . plugin (tauri_plugin_opener :: init ())
99+ . setup (| app | {
100+ let opener = app . opener ();
101+ opener . open_url (" https://example.com" , Some (" firefox" ))? ;
102+ opener . open_path (" /path/to/file" , Some (" firefox" ))? ;
103+ opener . reveal_item_in_dir (" /path/to/file" )? ;
104+ Ok (())
105+ })
106+ . run (tauri :: generate_context! ())
107+ . expect (" error while running tauri application" );
108+ }
74109```
75110
76111## Contributing
0 commit comments