File: filesystem-next.md | Updated: 11/15/2025
Hide navigation
Search
Ctrl K
Home Guides EAS Reference Learn
Reference version
SDK 52
Archive Expo Snack Discord and Forums Newsletter
Expo FileSystem (next)A library that provides access to the local file system on the device.
Android
iOS
tvOS
Bundled version:
~18.0.12
Copy page
The
nextversion of the FileSystem API is included in theexpo-file-systemlibrary. It can be used alongside the previous API, and offers a simplified, object oriented way of performing filesystem operations.
To provide quicker updates,
expo-file-system/nextis currently unsupported in Expo Go and Snack. To use it, create a development build .
expo-file-system/next provides access to the file system stored locally on the device. It can also download files from the network.
Terminal
Copy
- npx expo install expo-file-system
If you are installing this in an existing React Native app
, make sure to install expo
in your project.
example.ts
Copy
import { File, Paths } from 'expo-file-system/next'; try { const file = new File(Paths.cache, 'example.txt'); file.create(); // can throw an error if the file already exists or no permission to create it file.write('Hello, world!'); console.log(file.text()); // Hello, world! } catch (error) { console.error(error); }
example.ts
Copy
import { Directory, File, Paths } from 'expo-file-system/next'; const url = 'https://pdfobject.com/pdf/sample.pdf'; const destination = new Directory(Paths.cache, 'pdfs'); try { destination.create(); const output = await File.downloadFileAsync(url, destination); console.log(output.exists); // true console.log(output.uri); // path to the downloaded file, e.g. '${cacheDirectory}/pdfs/sample.pdf' } catch (error) { console.error(error); }
example.ts
Copy
import { Directory, File, Paths } from 'expo-file-system/next'; try { const file = new File(Paths.document, 'example.txt'); file.create(); console.log(file.uri); // '${documentDirectory}/example.txt' file.move(Paths.cache); console.log(file.uri); // '${cacheDirectory}/example.txt' file.move(new Directory(Paths.cache, 'newFolder')); console.log(file.uri); // '${cacheDirectory}/newFolder/example.txt' } catch (error) { console.error(error); }
example.ts
Copy
import * as FileSystem from 'expo-file-system'; import { File, Paths } from 'expo-file-system/next'; try { const file = new File(Paths.cache, 'example.txt'); const content = await FileSystem.readAsStringAsync(file.uri); console.log(content); } catch (error) { console.error(error); }
example.ts
Copy
import { Directory, Paths } from 'expo-file-system/next'; function printDirectory(directory: Directory, indent: number = 0) { console.log(`${' '.repeat(indent)} + ${directory.name}`); const contents = directory.list(); for (const item of contents) { if (item instanceof Directory) { printDirectory(item, indent + 2); } else { console.log(`${' '.repeat(indent + 2)} - ${item.name} (${item.size} bytes)`); } } } try { printDirectory(new Directory(Paths.cache)); } catch (error) { console.error(error); }
Show More
DirectoryAndroid
iOS
tvOS
Type: Class extends FileSystemDirectory
Represents a directory on the filesystem.
A Directory instance can be created for any path, and does not need to exist on the filesystem during creation.
Directory Properties
existsAndroid
iOS
tvOS
Type: boolean
A boolean representing if a directory exists. true if the directory exists, false otherwise. Also false if the application does not have read access to the file.
uriAndroid
iOS
tvOS
Read Only • Type: string
Represents the directory URI. The field is read-only, but it may change as a result of calling some methods such as move.
nameAndroid
iOS
tvOS
Type: string
Directory name.
parentDirectoryAndroid
iOS
tvOS
Type: [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory)
Directory containing the file.
Directory Methods
copy(destination)Android
iOS
tvOS
| Parameter | Type |
| --- | --- |
| destination | [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) |
Copies a directory.
Returns:
any
create()Android
iOS
tvOS
Creates a directory that the current uri points to.
Returns:
void
delete()Android
iOS
tvOS
Deletes a directory. Also deletes all files and directories inside the directory.
Returns:
void
list()Android
iOS
tvOS
Lists the contents of a directory. Calling this method if the parent directory does not exist will throw an error.
Returns:
([File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) | [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) )[]
An array of Directory and File instances.
move(destination)Android
iOS
tvOS
| Parameter | Type |
| --- | --- |
| destination | [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) |
Moves a directory. Updates the uri property that now points to the new location.
Returns:
any
FileAndroid
iOS
tvOS
Type: Class extends FileSystemFile
File Properties
existsAndroid
iOS
tvOS
Type: boolean
A boolean representing if a file exists. true if the file exists, false otherwise. Also false if the application does not have read access to the file.
md5Android
iOS
tvOS
Literal type: union
An md5 hash of the file. Null if the file does not exist or it cannot be read.
Acceptable values are: null | string
sizeAndroid
iOS
tvOS
Literal type: union
A size of the file in bytes. Null if the file does not exist or it cannot be read.
Acceptable values are: null | number
uriAndroid
iOS
tvOS
Read Only • Type: string
Represents the file URI. The field is read-only, but it may change as a result of calling some methods such as move.
extensionAndroid
iOS
tvOS
Type: string
File extension.
Example
'.png'
nameAndroid
iOS
tvOS
Type: string
File name. Includes the extension.
parentDirectoryAndroid
iOS
tvOS
Type: [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory)
Directory containing the file.
File Methods
base64()Android
iOS
tvOS
Retrieves content of the file as base64.
Returns:
string
The contents of the file as a base64 string.
bytes()Android
iOS
tvOS
Retrieves byte content of the entire file.
Returns:
[Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
The contents of the file as a Uint8Array.
copy(destination)Android
iOS
tvOS
| Parameter | Type |
| --- | --- |
| destination | [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) |
Copies a file.
Returns:
any
create()Android
iOS
tvOS
Creates a file.
Returns:
void
delete()Android
iOS
tvOS
Deletes a file.
Returns:
void
downloadFileAsync(url, destination)Android
iOS
tvOS
| Parameter | Type | Description |
| --- | --- | --- |
| url | string | The URL of the file to download. |
| destination | [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) | The destination directory or file. If a directory is provided, the resulting filename will be determined based on the response headers. |
A static method that downloads a file from the network.
Returns:
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) <[File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) >
A promise that resolves to the downloaded file.
Example
const file = await File.downloadFileAsync("https://example.com/image.png", new Directory(Paths.document));
move(destination)Android
iOS
tvOS
| Parameter | Type |
| --- | --- |
| destination | [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) |
Moves a directory. Updates the uri property that now points to the new location.
Returns:
any
open()Android
iOS
tvOS
Returns a FileHandle object that can be used to read and write data to the file.
Returns:
[FileHandle](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#filehandle)
readableStream()Android
iOS
tvOS
Returns:
[ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) <[Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) >
text()Android
iOS
tvOS
Retrieves text from the file.
Returns:
string
The contents of the file as string.
writableStream()Android
iOS
tvOS
Returns:
[WritableStream](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream) <[Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) >
write(content)Android
iOS
tvOS
| Parameter | Type | Description |
| --- | --- | --- |
| content | string \| [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | The content to write into the file. |
Writes content to the file.
Returns:
void
PathsAndroid
iOS
tvOS
Type: Class extends PathUtilities
Paths Properties
appleSharedContainersAndroid
iOS
tvOS
Type: Record<string, [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) >
cacheAndroid
iOS
tvOS
Type: [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory)
A property containing the cache directory – a place to store files that can be deleted by the system when the device runs low on storage.
documentAndroid
iOS
tvOS
Type: [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory)
A property containing the document directory – a place to store files that are safe from being deleted by the system.
Paths Methods
basename(path, ext)Android
iOS
tvOS
| Parameter | Type | Description |
| --- | --- | --- |
| path | string \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) \| [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) | The path to get the base name from. |
| ext(optional) | string | An optional file extension. |
Returns the base name of a path.
Returns:
string
A string representing the base name.
dirname(path)Android
iOS
tvOS
| Parameter | Type | Description |
| --- | --- | --- |
| path | string \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) \| [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) | The path to get the directory name from. |
Returns the directory name of a path.
Returns:
string
A string representing the directory name.
extname(path)Android
iOS
tvOS
| Parameter | Type | Description |
| --- | --- | --- |
| path | string \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) \| [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) | The path to get the extension from. |
Returns the extension of a path.
Returns:
string
A string representing the extension.
isAbsolute(path)Android
iOS
tvOS
| Parameter | Type | Description |
| --- | --- | --- |
| path | string \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) \| [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) | The path to check. |
Checks if a path is absolute.
Returns:
boolean
true if the path is absolute, false otherwise.
join(...paths)Android
iOS
tvOS
| Parameter | Type | Description |
| --- | --- | --- |
| ...paths | (string \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) \| [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) )[] | An array of path segments. |
Joins path segments into a single path.
Returns:
string
A string representing the joined path.
normalize(path)Android
iOS
tvOS
| Parameter | Type | Description |
| --- | --- | --- |
| path | string \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) \| [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) | The path to normalize. |
Normalizes a path.
Returns:
string
A string representing the normalized path.
parse(path)Android
iOS
tvOS
| Parameter | Type | Description |
| --- | --- | --- |
| path | string \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) \| [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) | The path to parse. |
Parses a path into its components.
Returns:
{ base: string, dir: string, ext: string, name: string, root: string }
An object containing the parsed path components.
relative(from, to)Android
iOS
tvOS
| Parameter | Type | Description |
| --- | --- | --- |
| from | string \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) \| [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) | The base path. |
| to | string \| [File](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#file) \| [Directory](https://docs.expo.dev/versions/v52.0.0/sdk/filesystem-next#directory) | The relative path. |
Resolves a relative path to an absolute path.
Returns:
string
A string representing the resolved path.