Michael Charles Aubrey

https://MichaelCharl.es/Aubrey

Mapping Tauri Path Helper Functions on macOS

Mapping Tauri Path Helper Functions on macOS

Michael Charles Aubrey // Mon Nov 11 2024

I'm writing a desktop app using Tauri v2 and have been struggling working with the filesystem APIs. Tauri provides several helper functions through @tauri-apps/api/path to help you find common directories such as appCacheDir() and appConfigDir(). While there is official documentation available, I couldn't find it at first, and it's structured in a way that makes it difficult to quickly scan and understand where each path actually maps to at a glance.

For the purposes of this article, we'll say that you've set up your tauri.conf.json with an identifier like com.example.myapp.

I wrote a small utility function to map out exactly where each of these helper functions point to on macOS. After running it, here's what I found:

appCacheDir() -> /Users/{username}/Library/Caches/com.example.myapp
appConfigDir() -> /Users/{username}/Library/Application Support/com.example.myapp
appDataDir() -> /Users/{username}/Library/Application Support/com.example.myapp
appLocalDataDir() -> /Users/{username}/Library/Application Support/com.example.myapp
appLogDir() -> /Users/{username}/Library/Logs/com.example.myapp
audioDir() -> /Users/{username}/Music
cacheDir() -> /Users/{username}/Library/Caches
configDir() -> /Users/{username}/Library/Application Support
dataDir() -> /Users/{username}/Library/Application Support
desktopDir() -> /Users/{username}/Desktop
documentDir() -> /Users/{username}/Documents
downloadDir() -> /Users/{username}/Downloads
executableDir() -> Error: unknown path
fontDir() -> /Users/{username}/Library/Fonts
homeDir() -> /Users/{username}
localDataDir() -> /Users/{username}/Library/Application Support
pictureDir() -> /Users/{username}/Pictures
publicDir() -> /Users/{username}/Public
resourceDir() -> /Users/{username}/Projects/personal/myapp/src-tauri/target/debug
tempDir() -> /var/folders/wk/{temp_folder}/T/
templateDir() -> Error: unknown path
videoDir() -> /Users/{username}/Movies

Things of note:

  1. The app-specific directories (appCacheDir, appConfigDir, etc.) append your app identifier to the standard system paths
  2. executableDir and templateDir aren't available on macOS
  3. resourceDir points to your debug build directory during development
  4. Several directories map to the same location (e.g., appConfigDir, appDataDir, and appLocalDataDir)

These paths are likely different on Linux and especially on Windows. I might write a follow-up article on those platforms as well if I can find time. In the meantime, I hope this is helpful to anyone else working with Tauri on macOS.