Ir al contenido

path

Esta página aún no está disponible en tu idioma.

The path module provides utilities for working with file and directory paths.

This package is also accessible with window.__TAURI__.path when app.withGlobalTauri in tauri.conf.json is set to true.

It is recommended to allowlist only the APIs you use for optimal bundle size and security.

Platform-specific

  • Android: The user directories are sandboxed per app. desktopDir, executableDir, fontDir, runtimeDir and templateDir — and the matching BaseDirectory variants — do not exist on Android at all. The remaining ones resolve inside the app’s own storage, so they are not shared with other apps, and videoDir resolves to the app-specific Movies directory.
  • iOS: Every directory resolves inside the app sandbox, so paths are private to your app and change between installs. Resolve them at runtime instead of persisting absolute paths.

All commands used by this module are part of the core:path:default permission set, which is enabled by default, so no extra capability configuration is needed.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L35

2.0.0

AppCache: 16;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L104

appCacheDir for more information.

AppConfig: 13;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L92

appConfigDir for more information.

AppData: 14;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L96

appDataDir for more information.

AppLocalData: 15;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L100

appLocalDataDir for more information.

AppLog: 17;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L108

appLogDir for more information.

Audio: 1;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L39

audioDir for more information.

Cache: 2;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L43

cacheDir for more information.

Config: 3;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L47

configDir for more information.

Data: 4;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L51

dataDir for more information.

Desktop: 18;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L116

desktopDir for more information.

Platform-specific

  • Android: Unsupported, this variant does not exist on Android.

Document: 6;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L59

documentDir for more information.

Download: 7;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L63

downloadDir for more information.

Executable: 19;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L124

executableDir for more information.

Platform-specific

  • Android: Unsupported, this variant does not exist on Android.

Font: 20;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L132

fontDir for more information.

Platform-specific

  • Android: Unsupported, this variant does not exist on Android.

Home: 21;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L136

homeDir for more information.

LocalData: 5;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L55

localDataDir for more information.

Picture: 8;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L67

pictureDir for more information.

Public: 9;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L71

publicDir for more information.

Resource: 11;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L84

resourceDir for more information.

Runtime: 22;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L144

runtimeDir for more information.

Platform-specific

  • Android: Unsupported, this variant does not exist on Android.

Temp: 12;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L88

tempDir for more information.

Template: 23;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L152

templateDir for more information.

Platform-specific

  • Android: Unsupported, this variant does not exist on Android.

Video: 10;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L80

videoDir for more information.

Platform-specific

  • Android: Resolves to the app-specific Movies directory since 2.12.0, see videoDir.

function appCacheDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L217

Returns the path to the suggested directory for your app’s cache files. Resolves to ${cacheDir}/${bundleIdentifier}, where bundleIdentifier is the identifier value configured in tauri.conf.json.

Promise<string>

import { appCacheDir } from '@tauri-apps/api/path';
const appCacheDirPath = await appCacheDir();

1.2.0


function appConfigDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L166

Returns the path to the suggested directory for your app’s config files. Resolves to ${configDir}/${bundleIdentifier}, where bundleIdentifier is the identifier value configured in tauri.conf.json.

Promise<string>

import { appConfigDir } from '@tauri-apps/api/path';
const appConfigDirPath = await appConfigDir();

1.2.0


function appDataDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L183

Returns the path to the suggested directory for your app’s data files. Resolves to ${dataDir}/${bundleIdentifier}, where bundleIdentifier is the identifier value configured in tauri.conf.json.

Promise<string>

import { appDataDir } from '@tauri-apps/api/path';
const appDataDirPath = await appDataDir();

1.2.0


function appLocalDataDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L200

Returns the path to the suggested directory for your app’s local data files. Resolves to ${localDataDir}/${bundleIdentifier}, where bundleIdentifier is the identifier value configured in tauri.conf.json.

Promise<string>

import { appLocalDataDir } from '@tauri-apps/api/path';
const appLocalDataDirPath = await appLocalDataDir();

1.2.0


function appLogDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L670

Returns the path to the suggested directory for your app’s log files.

Platform-specific

  • Linux: Resolves to ${configDir}/${bundleIdentifier}/logs.
  • macOS: Resolves to ${homeDir}/Library/Logs/{bundleIdentifier}
  • Windows: Resolves to ${configDir}/${bundleIdentifier}/logs.

Promise<string>

import { appLogDir } from '@tauri-apps/api/path';
const appLogDirPath = await appLogDir();

1.2.0


function audioDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L239

Returns the path to the user’s audio directory.

Platform-specific

  • Linux: Resolves to xdg-user-dirs’ XDG_MUSIC_DIR.
  • macOS: Resolves to $HOME/Music.
  • Windows: Resolves to {FOLDERID_Music}.

Promise<string>

import { audioDir } from '@tauri-apps/api/path';
const audioDirPath = await audioDir();

1.0.0


function basename(path, ext?): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L800

Returns the last portion of a path. Trailing directory separators are ignored.

Parameter Type Description
path string -
ext? string An optional file extension to be removed from the returned path.

Promise<string>

import { basename } from '@tauri-apps/api/path';
const base = await basename('path/to/app.conf');
assert(base === 'app.conf');

1.0.0


function cacheDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L261

Returns the path to the user’s cache directory.

Platform-specific

  • Linux: Resolves to $XDG_CACHE_HOME or $HOME/.cache.
  • macOS: Resolves to $HOME/Library/Caches.
  • Windows: Resolves to {FOLDERID_LocalAppData}.

Promise<string>

import { cacheDir } from '@tauri-apps/api/path';
const cacheDirPath = await cacheDir();

1.0.0


function configDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L283

Returns the path to the user’s config directory.

Platform-specific

  • Linux: Resolves to $XDG_CONFIG_HOME or $HOME/.config.
  • macOS: Resolves to $HOME/Library/Application Support.
  • Windows: Resolves to {FOLDERID_RoamingAppData}.

Promise<string>

import { configDir } from '@tauri-apps/api/path';
const configDirPath = await configDir();

1.0.0


function dataDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L305

Returns the path to the user’s data directory.

Platform-specific

  • Linux: Resolves to $XDG_DATA_HOME or $HOME/.local/share.
  • macOS: Resolves to $HOME/Library/Application Support.
  • Windows: Resolves to {FOLDERID_RoamingAppData}.

Promise<string>

import { dataDir } from '@tauri-apps/api/path';
const dataDirPath = await dataDir();

1.0.0


function delimiter(): string;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L710

Returns the platform-specific path segment delimiter:

  • ; on Windows
  • : on POSIX

string

2.0.0


function desktopDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L330

Returns the path to the user’s desktop directory.

Platform-specific

  • Android: Unsupported. Android has no desktop directory, the BaseDirectory.Desktop variant does not exist there and the call rejects.

  • Linux: Resolves to xdg-user-dirs’ XDG_DESKTOP_DIR.

  • macOS: Resolves to $HOME/Desktop.

  • Windows: Resolves to {FOLDERID_Desktop}.

Promise<string>

import { desktopDir } from '@tauri-apps/api/path';
const desktopPath = await desktopDir();

1.0.0


function dirname(path): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L769

Returns the parent directory of a given path. Trailing directory separators are ignored.

Parameter Type
path string

Promise<string>

import { dirname } from '@tauri-apps/api/path';
const dir = await dirname('/path/to/somedir/');
assert(dir === '/path/to');

1.0.0


function documentDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L352

Returns the path to the user’s document directory.

Promise<string>

import { documentDir } from '@tauri-apps/api/path';
const documentDirPath = await documentDir();

Platform-specific

  • Linux: Resolves to xdg-user-dirs’ XDG_DOCUMENTS_DIR.
  • macOS: Resolves to $HOME/Documents.
  • Windows: Resolves to {FOLDERID_Documents}.

1.0.0


function downloadDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L374

Returns the path to the user’s download directory.

Platform-specific

  • Linux: Resolves to xdg-user-dirs’ XDG_DOWNLOAD_DIR.
  • macOS: Resolves to $HOME/Downloads.
  • Windows: Resolves to {FOLDERID_Downloads}.

Promise<string>

import { downloadDir } from '@tauri-apps/api/path';
const downloadDirPath = await downloadDir();

1.0.0


function executableDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L399

Returns the path to the user’s executable directory.

Platform-specific

  • Android: Unsupported. The BaseDirectory.Executable variant does not exist there and the call rejects.

  • Linux: Resolves to $XDG_BIN_HOME/../bin or $XDG_DATA_HOME/../bin or $HOME/.local/bin.

  • macOS: Not supported.

  • Windows: Not supported.

Promise<string>

import { executableDir } from '@tauri-apps/api/path';
const executableDirPath = await executableDir();

1.0.0


function extname(path): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L784

Returns the extension of the path.

Parameter Type
path string

Promise<string>

import { extname } from '@tauri-apps/api/path';
const ext = await extname('/path/to/file.html');
assert(ext === 'html');

1.0.0


function fontDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L424

Returns the path to the user’s font directory.

Platform-specific

  • Android: Unsupported. The BaseDirectory.Font variant does not exist there and the call rejects.

  • Linux: Resolves to $XDG_DATA_HOME/fonts or $HOME/.local/share/fonts.

  • macOS: Resolves to $HOME/Library/Fonts.

  • Windows: Not supported.

Promise<string>

import { fontDir } from '@tauri-apps/api/path';
const fontDirPath = await fontDir();

1.0.0


function homeDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L446

Returns the path to the user’s home directory.

Platform-specific

  • Linux: Resolves to $HOME.
  • macOS: Resolves to $HOME.
  • Windows: Resolves to {FOLDERID_Profile}.

Promise<string>

import { homeDir } from '@tauri-apps/api/path';
const homeDirPath = await homeDir();

1.0.0


function isAbsolute(path): Promise<boolean>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L814

Returns whether the path is absolute or not.

Parameter Type
path string

Promise<boolean>

import { isAbsolute } from '@tauri-apps/api/path';
assert(await isAbsolute('/home/tauri'));

1.0.0


function join(...paths): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L754

Joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.

Parameter Type
…paths string[]

Promise<string>

import { join, appDataDir } from '@tauri-apps/api/path';
const appDataDirPath = await appDataDir();
const path = await join(appDataDirPath, 'users', 'tauri', 'avatar.png');

1.0.0


function localDataDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L468

Returns the path to the user’s local data directory.

Platform-specific

  • Linux: Resolves to $XDG_DATA_HOME or $HOME/.local/share.
  • macOS: Resolves to $HOME/Library/Application Support.
  • Windows: Resolves to {FOLDERID_LocalAppData}.

Promise<string>

import { localDataDir } from '@tauri-apps/api/path';
const localDataDirPath = await localDataDir();

1.0.0


function normalize(path): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L739

Normalizes the given path, resolving '..' and '.' segments and resolve symbolic links.

Parameter Type
path string

Promise<string>

import { normalize, appDataDir } from '@tauri-apps/api/path';
const appDataDirPath = await appDataDir();
const path = await normalize(`${appDataDirPath}/../users/tauri/avatar.png`);

1.0.0


function pictureDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L490

Returns the path to the user’s picture directory.

Platform-specific

  • Linux: Resolves to xdg-user-dirs’ XDG_PICTURES_DIR.
  • macOS: Resolves to $HOME/Pictures.
  • Windows: Resolves to {FOLDERID_Pictures}.

Promise<string>

import { pictureDir } from '@tauri-apps/api/path';
const pictureDirPath = await pictureDir();

1.0.0


function publicDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L512

Returns the path to the user’s public directory.

Platform-specific

  • Linux: Resolves to xdg-user-dirs’ XDG_PUBLICSHARE_DIR.
  • macOS: Resolves to $HOME/Public.
  • Windows: Resolves to {FOLDERID_Public}.

Promise<string>

import { publicDir } from '@tauri-apps/api/path';
const publicDirPath = await publicDir();

1.0.0


function resolve(...paths): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L724

Resolves a sequence of paths or path segments into an absolute path.

Parameter Type
…paths string[]

Promise<string>

import { resolve, appDataDir } from '@tauri-apps/api/path';
const appDataDirPath = await appDataDir();
const path = await resolve(appDataDirPath, '..', 'users', 'tauri', 'avatar.png');

1.0.0


function resolveResource(resourcePath): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L565

Resolve the path to a resource file.

Parameter Type Description
resourcePath string The path to the resource. Must follow the same syntax as defined in tauri.conf.json > bundle > resources, i.e. keeping subfolders and parent dir components (../).

Promise<string>

The full path to the resource.

import { resolveResource } from '@tauri-apps/api/path';
const resourcePath = await resolveResource('script.sh');

1.0.0


function resourceDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L545

Returns the path to the application’s resource directory. To resolve a resource path, see resolveResource.

Although we provide the exact path where this function resolves to, this is not a contract and things might change in the future

  • Windows: Resolves to the directory that contains the main executable.
  • Linux: When running in an AppImage, the APPDIR variable will be set to the mounted location of the app, and the resource dir will be ${APPDIR}/usr/lib/${exe_name}. If not running in an AppImage, the path is /usr/lib/${exe_name}. When running the app from src-tauri/target/(debug|release)/, the path is ${exe_dir}/../lib/${exe_name}.
  • macOS: Resolves to ${exe_dir}/../Resources (inside .app).
  • iOS: Resolves to ${exe_dir}/assets.
  • Android: Currently the resources are stored in the APK as assets so it’s not a normal file system path, we return a special URI prefix asset://localhost/ here that can be used with the file system plugin,

Promise<string>

import { resourceDir } from '@tauri-apps/api/path';
const resourceDirPath = await resourceDir();

1.0.0


function runtimeDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L591

Returns the path to the user’s runtime directory.

Platform-specific

  • Android: Unsupported. The BaseDirectory.Runtime variant does not exist there and the call rejects.

  • Linux: Resolves to $XDG_RUNTIME_DIR.

  • macOS: Not supported.

  • Windows: Not supported.

Promise<string>

import { runtimeDir } from '@tauri-apps/api/path';
const runtimeDirPath = await runtimeDir();

1.0.0


function sep(): string;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L699

Returns the platform-specific path segment separator:

  • \ on Windows
  • / on POSIX

string

2.0.0


function tempDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L686

Returns a temporary directory.

Promise<string>

import { tempDir } from '@tauri-apps/api/path';
const temp = await tempDir();

2.0.0


function templateDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L616

Returns the path to the user’s template directory.

Platform-specific

  • Android: Unsupported. The BaseDirectory.Template variant does not exist there and the call rejects.

  • Linux: Resolves to xdg-user-dirs’ XDG_TEMPLATES_DIR.

  • macOS: Not supported.

  • Windows: Resolves to {FOLDERID_Templates}.

Promise<string>

import { templateDir } from '@tauri-apps/api/path';
const templateDirPath = await templateDir();

1.0.0


function videoDir(): Promise<string>;

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/path.ts#L648

Returns the path to the user’s video directory.

Platform-specific

  • Linux: Resolves to xdg-user-dirs’ XDG_VIDEOS_DIR.
  • macOS: Resolves to $HOME/Movies.
  • Windows: Resolves to {FOLDERID_Videos}.
  • Android: Resolves to the app-specific Movies directory (getExternalFilesDir(DIRECTORY_MOVIES)), typically .../files/Movies. It is private to your app and removed when the app is uninstalled.
  • iOS: Resolves inside the app sandbox.

Promise<string>

import { videoDir } from '@tauri-apps/api/path';
const videoDirPath = await videoDir();

Breaking change on Android in tauri 2.12.0: videoDir() and the $VIDEO path variable used to resolve to external cache storage (.../cache) and now resolve to the app-specific Movies directory (.../files/Movies). Files written to the old location are not found at the new one, so migrate them or update your path assumptions.

1.0.0


© 2026 Tauri Contributors. CC-BY / MIT