Skip to content

Composable API

Use useVueFinder(id) when you want to control a mounted VueFinder instance programmatically.

Quick Start

vue
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useVueFinder } from 'vuefinder';

const finder = ref<ReturnType<typeof useVueFinder> | null>(null);

onMounted(() => {
  finder.value = useVueFinder('my-local-finder');
});

const refresh = async () => {
  await finder.value?.refresh();
};

const createFolder = async () => {
  await finder.value?.createFolder('New Folder API');
};

const previewFile = () => {
  finder.value?.preview('local://docs/readme.txt');
};

const testNotify = () => {
  finder.value?.notify('success', 'Composable notify test');
};
</script>

<template>
  <vue-finder id="my-local-finder" :driver="driver" />
  <button @click="refresh">Refresh</button>
  <button @click="createFolder">Create Folder</button>
  <button @click="previewFile">Preview File</button>
  <button @click="testNotify">Test Notify</button>
</template>

All Methods

useVueFinder(id) returns a VueFinderComposable with the following methods:

MethodSignatureDescription
refresh() => Promise<void>Reload the current directory
open(path: string) => Promise<void>Navigate to a path
getPath() => stringCurrent directory path
getFiles() => DirEntry[]Entries in the current directory
getStorages() => string[]Available storage names
isLoading() => booleanWhether a request is in flight
isReadOnly() => booleanWhether the current directory is read-only

Selection

MethodSignatureDescription
select(paths: string[]) => voidSelect the given paths
selectOne(path: string) => voidSelect a single path
clearSelection() => voidClear the selection
getSelectedPaths() => string[]Paths of the selected items

File operations

MethodSignatureDescription
createFolder(name: string, path?: string) => Promise<void>Create a folder (in path or the current directory)
createFile(name: string, path?: string) => Promise<void>Create an empty file
delete(paths: string[], path?: string) => Promise<void>Delete items
rename(itemPath: string, newName: string, path?: string) => Promise<void>Rename an item
copy(sources: string[], destination: string, path?: string) => Promise<void>Copy items to a destination folder
move(sources: string[], destination: string, path?: string) => Promise<void>Move items to a destination folder

UI

MethodSignatureDescription
preview(path: string) => voidOpen the preview modal for a file
notify(type, message) => voidShow a notification (type: 'success' | 'error' | 'info' | 'warning')

See API Reference – Types for the full interface definition.

Notes

  • The target instance must be mounted. If not, useVueFinder(id) throws a descriptive error.
  • select(paths) only selects files currently loaded in the active directory.
  • Core operations (createFolder, rename, move, etc.) delegate to the configured driver.