Skip to content

Commit 09d19c7

Browse files
Verso integration blog (#3232)
1 parent b62cdbb commit 09d19c7

File tree

4 files changed

+116
-0
lines changed

4 files changed

+116
-0
lines changed

Diff for: astro.config.mjs

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ const authors = {
5858
title: 'Tauri Security',
5959
picture: '/authors/chip.png',
6060
},
61+
tony: {
62+
name: 'Tony',
63+
title: 'Tauri Development',
64+
picture: '/authors/tony.jpeg',
65+
},
6166
};
6267

6368
const site = 'https://v2.tauri.app';
3.61 MB
Binary file not shown.

Diff for: public/authors/tony.jpeg

17.3 KB
Loading

Diff for: src/content/docs/blog/tauri-verso-integration.md

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
title: Experimental Tauri Verso Integration
3+
date: 2025-03-17
4+
authors: [tony]
5+
excerpt: The first look of the integration with Verso, a browser based on Servo
6+
---
7+
8+
## What is Verso?
9+
10+
So first off, what is `Verso`? [`Verso`](https://github.com/versotile-org/verso) is a browser based on [`Servo`](https://servo.org/), a web browser rendering engine written in Rust
11+
12+
## Why using Verso instead of Servo directly?
13+
14+
I believe there're quite a lot of people having thought about using Servo but got intimidated by the complex APIs and just gave up, which frankly I was one of them, so the goal of building the Verso webview is to make it easy enough to understand and use so that people will actually start to experiment and use it
15+
16+
Servo itself is made to be relatively easy to embed compared to other browsers, but the APIs are still way too low level and it's quite daunting to use, you can take a look at the minimal example for running Servo with Winit at (note this is not even a fully functional example): https://github.com/servo/servo/blob/8d39d7706aee50971e848a5e31fc6bfd7ef552c1/components/servo/examples/winit_minimal.rs
17+
18+
And compared to that, Verso's API looks like this, which is much easier and ergonomic to use
19+
20+
```rust
21+
use std::env::current_exe;
22+
use std::thread::sleep;
23+
use std::time::Duration;
24+
use url::Url;
25+
use verso::VersoBuilder;
26+
27+
fn main() {
28+
let versoview_path = current_exe().unwrap().parent().unwrap().join("versoview");
29+
let controller = VersoBuilder::new()
30+
.with_panel(true)
31+
.maximized(true)
32+
.build(versoview_path, Url::parse("https://example.com").unwrap());
33+
loop {
34+
sleep(Duration::MAX);
35+
}
36+
}
37+
```
38+
39+
> https://github.com/versotile-org/verso/blob/2e853d4f3f4cb88274daa211b7a2eb3bd1517115/verso/src/main.rs
40+
41+
It's not to say Servo's API is bad though, as they need to support a lot more use cases while we just need it for building applications with Tauri
42+
43+
## `tauri-runtime-verso`
44+
45+
So let's talk about the integration with Tauri!
46+
47+
We choose to integrate Verso and Tauri through a new custom runtime [`tauri-runtime-verso`](https://github.com/versotile-org/tauri-runtime-verso) for this time, this is similar to our default runtime `tauri-runtime-wry`.
48+
49+
With this approach, you can easily swap out the runtime and use Tauri like what you'll normally do:
50+
51+
```rust
52+
use tauri_runtime_verso::{
53+
INVOKE_SYSTEM_SCRIPTS, VersoRuntime, set_verso_path, set_verso_resource_directory,
54+
};
55+
56+
fn main() {
57+
// You need to set this to the path of the versoview executable
58+
// before creating any of the webview windows
59+
set_verso_path("../verso/target/debug/versoview");
60+
// Set this to verso/servo's resources directory before creating any of the webview windows
61+
// this is optional but recommended, this directory will include very important things
62+
// like user agent stylesheet
63+
set_verso_resource_directory("../verso/resources");
64+
tauri::Builder::<VersoRuntime>::new()
65+
// Make sure to do this or some of the commands will not work
66+
.invoke_system(INVOKE_SYSTEM_SCRIPTS.to_owned())
67+
.run(tauri::generate_context!())
68+
.unwrap();
69+
}
70+
```
71+
72+
Just note that it's not as feature rich and powerful as the current backends used by Tauri in production yet, but it still has a lot to it, and we have built an example show casing it at https://github.com/versotile-org/tauri-runtime-verso/tree/main/examples/api
73+
74+
<video controls src="/assets/blog/verso-integration/dev-show-case.mp4" title="Verso integration show case"></video>
75+
76+
#### Features you can see from the video:
77+
78+
- We have all the functions the `tauri-cli` provides
79+
- We're using a modern framework, in this case [`React`](https://react.dev/)
80+
- We have our official log and opener plugins, they work exactly the same as if you're using Tauri with the other backends
81+
- Windowing functions work, including size, position, maximize, minimize, close, ...
82+
- [`Vite`](https://vitejs.dev/)'s css hot reload works as well
83+
- The `data-tauri-drag-region` attribute works
84+
85+
## Future works
86+
87+
Right now, Verso and `tauri-runtime-verso` are still in active development so we'll need to see as we go, but we do have something planned to do next
88+
89+
### Pre-built Verso executable
90+
91+
Releasing an easy to use pre-built Verso executable to help people get started with it quicker and easier, as currently you need to compile Verso yourself to get started
92+
93+
Also if possible, as a long term goal, we would like an evergreen shared Verso, similar to WebView2 on Windows which you would place it on the system and it would update itself automatically, and shared between multiple apps so you don't have to ship the browser inside your app to reduce the bundle size significantly
94+
95+
### More windowing and webview features support
96+
97+
We currently only support a small subset of features in Tauri, and we would like to expand this to include more things, and we have currently planned to support window decorations, window titles and transparency
98+
99+
### Initialization script without temporary files
100+
101+
Currently Servo can only take an userscript directory to run on document start which is ok but for the Tauri's use case, we would like to do this programmatically without the help of files, as that could result in left over temporary files that we never clean up
102+
103+
We have a [PR](https://github.com/servo/servo/pull/35388) merged in Servo just a few days ago and we should just need to use in Verso and then the `tarui-runtime-verso` so this is a coming soon!
104+
105+
### Customization unique to the Verso runtime
106+
107+
Tauri is largely made with the assumption of the underlying webview libraries, so there're very little ways to use many Verso specific futures right now, for example, setting the verso executable path and resources directory are being done through global variables, which is not really applicable to window specific features (for example setting rounded corners), so we would like to add support for that next
108+
109+
## Thank you
110+
111+
At the end we want to thank [NLNet](https://nlnet.nl/) for making this project possible by supporting it financially through grants!

0 commit comments

Comments
 (0)