API reference

All async methods return SmbTask<T>. Await with .result(). See Task model for subscribe and cancel patterns.

No methods match your search.

Overview

SMB()
SMB(): Smb
factory

Create a new SMB client instance. Each instance has its own connection pool and transfer store.

client.ts
import { SMB } from '@cetapod/react-native-smb';

const smb = SMB();

Connection

initialize
initialize(url, creds) → SmbTask<void>
task

Connect to server only — no share mounted. Use before listShares() or connectShare().

ParamTypeDescription
urlstringServer URL without share path
credsSmbCredentialsUsername and password
init.ts
await smb.initialize('smb://192.168.1.100', creds).result();
const shares = await smb.listShares().result();
connect
connect(url, creds) → SmbTask<SmbConnectionInfo>
task

Authenticate and mount the share from the URL in one step.

connect.ts
const info = await smb
  .connect('smb://nas.local/Media', creds)
  .result();

console.log(info.server, info.share, info.isConnected);
connectShare
connectShare(share) → SmbTask<SmbConnectionInfo>
task

Switch to a different share on an already-initialized server.

share.ts
await smb.initialize('smb://nas.local', creds).result();
const info = await smb.connectShare('Documents').result();
disconnect
disconnect() → SmbTask<void>
task

Close the SMB session and release all pool slots.

disconnect.ts
await smb.disconnect().result();
listShares
listShares() → SmbTask<SmbShareList[]>
task interactive

Enumerate available shares on the server. Requires prior initialize().

shares.ts
const shares = await smb.listShares().result();
shares.forEach((s) => console.log(s.name, s.comment));
isConnected / isInitialized
isConnected(): boolean · isInitialized(): boolean
sync

Synchronous state checks — no task required.

state.ts
if (smb.isConnected()) {
  // safe to browse files
}
if (smb.isInitialized()) {
  // server session exists, may not have share
}

File system

listDirectory
listDirectory(path, recursive?, maxDepth?) → SmbTask<SmbFileInfo[]>
task interactive*

List directory contents. maxDepth: -1 for unlimited recursion. Shallow lists use interactive slot; recursive uses metadata slot.

ParamTypeDefaultDescription
pathstringDirectory path
recursivebooleanfalseInclude subdirectories
maxDepthnumber-1Max recursion depth (-1 = unlimited)
list.ts
const entries = await smb
  .listDirectory('/Photos', false)
  .result();

const tree = await smb
  .listDirectory('/', true, 3)
  .result();
getPathInfo
getPathInfo(path) → SmbTask<SmbFileInfo>
task interactive

Get metadata for a single file or directory.

info.ts
const info = await smb.getPathInfo('/document.pdf').result();
console.log(info.size, info.modifiedAt);
downloadFile
downloadFile(remotePath, localPath) → SmbTask<void>
task

Download a remote file to a local path. Use .subscribe() for progress.

download.ts
const task = smb.downloadFile(
  '/video.mp4',
  `${FileSystem.documentDirectory}video.mp4`,
);
task.subscribe((s) => console.log(s.progress, s.bytesPerSecond));
await task.result();
uploadFile
uploadFile(localPath, remotePath) → SmbTask<void>
task

Upload a local file to a remote SMB path.

upload.ts
const task = smb.uploadFile(
  '/local/photo.jpg',
  '/Photos/photo.jpg',
);
await task.result();
createDirectory
createDirectory(path) → SmbTask<void>
task interactive

Create a directory. Creates parent directories as needed.

mkdir.ts
await smb.createDirectory('/Projects/2026/Q1').result();
deleteItem
deleteItem(path) → SmbTask<void>
task

Delete a file or directory. Directories are removed recursively.

delete.ts
await smb.deleteItem('/old-backup').result();
renameItem
renameItem(path, newName) → SmbTask<void>
task interactive

Rename in place. newName is the basename only, not a full path.

rename.ts
await smb.renameItem('/draft.txt', 'final.txt').result();
moveItem
moveItem(from, to) → SmbTask<void>
task interactive

Move a file or directory to a new path.

move.ts
await smb.moveItem('/inbox/file.pdf', '/archive/file.pdf').result();
copyItem
copyItem(from, to, recursive?) → SmbTask<void>
task

Copy a file or directory. Set recursive: true for directories.

copy.ts
await smb.copyItem('/templates', '/backup/templates', true).result();
duplicateItem
duplicateItem(path) → SmbTask<string>
task

Duplicate a file or folder in place. Returns the new path.

duplicate.ts
const newPath = await smb.duplicateItem('/report.pdf').result();
// "/report copy.pdf"
getSecurityDescriptor
getSecurityDescriptor(path) → SmbTask<SmbSecurityDescriptor>
task interactive

Read Windows ACL / security descriptor for a path.

acl.ts
const sd = await smb.getSecurityDescriptor('/shared').result();
sd.dacl.aces.forEach((ace) => console.log(ace.sid, ace.mask));

Pool & lifecycle

getPoolInfo
getPoolInfo() → PoolInfo
sync

Snapshot of all connection pool slots. See Architecture.

pool.ts
const info = smb.getPoolInfo();
info.slots.forEach((s) => console.log(s.index, s.state, s.kind));
subscribePoolInfo
subscribePoolInfo(cb) → string · unsubscribePoolInfo(id)
sync

Subscribe to live pool state changes. Returns a listener ID for unsubscribe.

pool-sub.ts
const id = smb.subscribePoolInfo((snap) => {
  console.log(snap.slots);
});
smb.unsubscribePoolInfo(id);
resetPool / dispose
resetPool(): void · dispose(): void
sync

resetPool() disconnects all slots. dispose() tears down the transfer store — call on logout.

lifecycle.ts
smb.resetPool();
smb.dispose();

Hooks

useSubscribe
useSubscribe(task) → SubscribeHandle
hook

React binding for SmbTask.subscribe(). Subscribes automatically on mount and whenever task changes; unsubscribes on unmount / task change.

ReturnsTypeDescription
subscribefunctionAttach an extra listener on top of the automatic subscription; returns unsubscribe
cancelfunctionAbort the task
progressnumberLatest progress 0–1
statusTaskStatusLatest status
snapshotSmbTaskState | nullFull state object
taskSmbTask | nullOriginal task ref
useTransfers / useTransferActions
useTransfers(smb) → SmbTaskState[] · useTransferActions(smb)
hook

Power a transfer tray UI — all active download/upload/copy tasks in one array.

useTransferActionsDescription
clearCompleted()Remove finished transfers from tray
hide(taskId)Hide a specific transfer
tray.tsx
const transfers = useTransfers(smb);
const { clearCompleted, hide } = useTransferActions(smb);

Utilities

Path helpers
normalizePath · splitPath · joinPath · getParentPath · getFileName
util
FunctionDescription
normalizePath(path)Forward slashes, trim trailing /
splitPath(path)Returns PathComponents
joinPath(dir, name)Combine directory and filename
getParentPath(path)Parent directory
getFileName(path)Filename from full path
paths.ts
import { splitPath, joinPath, normalizePath } from '@cetapod/react-native-smb';

const { parentDirectory, extension } = splitPath('/docs/report.pdf');
const path = joinPath(parentDirectory, 'archive.pdf');
Display helpers
generateCopyName · formatFileSize · formatDate
util
FunctionDescription
generateCopyName(base, ext, existing)"file copy 2.pdf" naming
formatFileSize(bytes)"1.5 MB" human-readable
formatDate(timestamp)Locale date/time from Unix seconds
display.ts
formatFileSize(1536000);  // "1.46 MB"
formatDate(file.modifiedAt);

Label helpers

Labels & predicates
statusLabel · operationLabel · isTransferKind · isDeterminateKind · isTerminalStatus
util
FunctionInputReturns
statusLabelTaskStatus"running", "success", etc.
operationLabelSmbOperatorKind"Download", "List directory", etc.
isTransferKindSmbOperatorKindDownload, upload, copy, duplicate
isDeterminateKindSmbOperatorKindSame as transfer kinds
isTerminalStatusTaskStatusSuccess, error, or cancelled