Can I build Drift in Tauri?
Can I build this in tauri tell me ?
Yes, you can definitely build Drift in Tauri, but it is not a direct "plug-and-play" migration. Since Drift relies on several native features (like screen capturing and global input hooks), you would need to replace the Electron-specific parts with Rust equivalents.
Here is the breakdown of what would be required to port Drift to Tauri:
###1. Frontend (Next.js)
Drift is built with Next.js. Tauri supports Next.js perfectly.
- The Good: You can keep almost all of your UI components, Tailwind CSS, and Framer Motion logic.
- The Change: You would likely want to switch to a static export (
output: 'export'innext.config.mjs) so that Tauri can bundle the frontend as a set of static files, making the app much faster and smaller.
###2. Screen Capturing
Currently, the Electron version uses desktopCapturer.getSources() to let users pick a screen or window.
- Tauri equivalent: Tauri doesn't have a built-in
desktopCapturer. You would need to use a plugin liketauri-plugin-screencaptureor write custom Rust code to enumerate windows and screens, then pass those IDs to the frontend to be used withnavigator.mediaDevices.getUserMedia.
###3. Global Click Tracking & Hotkeys
Drift uses uiohook-napi in the Electron main process to track mouse clicks and hotkeys globally (even when the app is in the background). This is how it knows where to "auto-zoom."
- Tauri equivalent: You would replace this Node.js native module with Rust crates like rdev or enigo. These allow you to listen for system-wide events in Rust and then "emit" them to your Next.js frontend via Tauri's event system.
###4. Video Processing (FFmpeg)
The project uses @ffmpeg/ffmpeg (the WASM version).
- The Good: This will work exactly the same in Tauri as it does in Electron/Chrome, as it runs entirely in the browser context (WebView).
###5. IPC (Communication)
- Electron: Uses
ipcRendererandipcMainviapreload.js. - Tauri: Uses
invokefor calling Rust functions from JS andlisten/emitfor two-way event streaming. You would need to rewrite theelectron/preload.jsandelectron/main.jslogic into a Taurimain.rsfile.
###Why move to Tauri?
- Smaller Bundle: The current Electron app is likely 100MB+. A Tauri version would be ~10MB.
- Performance: Rust-based global hooks are generally more efficient and stable than the
uiohook-napiwrapper used in Node. - Security: Tauri has a more restrictive (and thus secure) default posture than Electron.
###Summary
| Feature | Electron implementation | Tauri Port |
|---|---|---|
| UI | Next.js | Next.js (Static Export) |
| Window Mgmt | BrowserWindow | tauri::Window |
| Screen Capture | desktopCapturer | tauri-plugin-screencapture or custom Rust |
| Click Tracking | uiohook-napi | rdev or enigo (Rust crates) |
| Video Rendering | Canvas + WebWASM | Canvas + WebWASM (No change) |
Verdict: It is a very feasible project for Tauri, especially if you want a lightweight "Cinema-grade" recorder. However, expect to write 100-200 lines of Rust to handle the system-level hooks and screen selection.
END OF POST