Accessing Files & Saving Data
You can save data to the browser storage or to the local file system.
Using browser APIs like LocalStorage, SessionStorage & IndexedDB.
Using
fig.appwriteandfig.appreadUsing
fig.fwriteandfig.fread
Reading and Writing App Files
Every app has a directory where they can read and write freely. This can be used for storing user data or preferences.
Read data from file relative to ~/.fig/apps/app-name/ where app-name is defined by the fig:app meta tag.
fig.appread('prefs.json', (data, error) => {
})Write data to file relative to ~/.fig/apps/app-name/
let data = JSON.stringify({theme: "dark"})
fig.appwrite(path, data, (error) => {
})Reading and Writing User Files
Write data to file at path. The path is relative to the user's working directory when they launch your app.
To write a file to the path.
fig.fwrite(path, data, (error) => {
})Read data from file at path
fig.fread(path, (data, error) => {
})Normalize File paths
fig.normalizeFilepath
fig.normalizeFilePath(`${fig.env.PWD}/..`, (normalized) => {
console.log(normalized)
})Last updated