{"id":16133770,"url":"https://github.com/urfdvw/react-local-file-system","last_synced_at":"2025-03-18T15:31:02.092Z","repository":{"id":191511571,"uuid":"684809730","full_name":"urfdvw/react-local-file-system","owner":"urfdvw","description":"Tools for your react front end web app to access local files via File System API.","archived":false,"fork":false,"pushed_at":"2024-04-19T20:30:59.000Z","size":2194,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T17:50:43.020Z","etag":null,"topics":["file-system-api","react"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-local-file-system","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/urfdvw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-29T22:43:28.000Z","updated_at":"2025-02-07T12:55:56.000Z","dependencies_parsed_at":"2023-09-29T03:01:22.217Z","dependency_job_id":"9552f953-a3b5-421b-8cc5-fbb3236182a3","html_url":"https://github.com/urfdvw/react-local-file-system","commit_stats":null,"previous_names":["urfdvw/usefilesystem","urfdvw/react-local-file-system"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urfdvw%2Freact-local-file-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urfdvw%2Freact-local-file-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urfdvw%2Freact-local-file-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urfdvw%2Freact-local-file-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urfdvw","download_url":"https://codeload.github.com/urfdvw/react-local-file-system/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243933428,"owners_count":20370989,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["file-system-api","react"],"created_at":"2024-10-09T22:45:41.810Z","updated_at":"2025-03-18T15:31:01.531Z","avatar_url":"https://github.com/urfdvw.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-local-file-system\n\nThis package contains tools for your react front end web app to access local files via File System API.\nThis package only supports Chrome and Chromium-based browsers.\n\n## Install\n```\nnpm i react-local-file-system\n```\n\n## Quick setup\n\nThe minimal setup to use this package is to utilize the `FolderView` component for general file operations and to create a custom handler function, `onFileClick`, to manage any file click actions. Specifically, the `FolderView` component is used in the UI to access files, accepting a prop named `onFileClick` that takes a single parameter: `fileHandle`. The `onFileClick` function is triggered when a file is clicked in the UI, with `fileHandle` being the file handle of the clicked file.\n\nCode example:\n\n```js\nimport FolderView, { useFileSystem, getFileText } from \"react-local-file-system\";\n\nexport default function App() {\n    // get folder handler and status with useFileSystem hook\n    const { openDirectory, directoryReady, statusText, rootDirHandle } = useFileSystem();\n    // example onFileClick handler\n    async function onFileClick(fileHandle) {\n        console.log(\"file content of\", fileHandle.name, \":\", await getFileText(fileHandle));\n    }\n    // Show FolderView component only when its ready\n    return directoryReady ? (\n        \u003cFolderView rootFolder={rootDirHandle} onFileClick={onFileClick} /\u003e\n    ) : (\n        \u003c\u003e\n            \u003cbutton onClick={openDirectory}\u003eOpen Dir\u003c/button\u003e\n            \u003cp\u003e{statusText}\u003c/p\u003e\n        \u003c/\u003e\n    );\n}\n```\n\n## Demo\nThe live demo of the example above is here:\nhttps://urfdvw.github.io/react-local-file-system/\n\nFor the code of the live demo, please see the `demo` branch\n\n## Contents\n\n### `FolderView` component\nSupported operations\n- view\n    - click on file to trigger `onFileClick` function\n    - click on folder to open\n    - click on folder in the path to go back\n- context menu\n    - rename\n    - duplicate\n    - remove\n- add\n    - add new file\n    - add new folder\n- drag and drop on to folder\n    - move file or folder\n\n### `useFileSystem` hook\nreturned objects\n- methods:\n    - `openDirectory`: function handle to open a directory, or switch to a new directory\n    - `path2FolderHandles`: given a directory path (`string`) return a folder handle\n- values:\n    - `rootDirHandle`: the folder handle of the opened folder\n    - `directoryReady`: `boolean` indicator of whether the folder handles in the hook are ready to be used\n    - `statusText`: `string` text indicator of status of the folder handles.\n\n### fileSystem util functions\nfunctions \n- file level\n    - `writeFileText(fileHandle, text) -\u003e void`: write text to a file\n    - `getFileText(fileHandle) -\u003e string`: read text from a file\n- folder level (docs coming, please see source code for help at the moment)\n\n## PeerDependency\n```\n\"@mui/icons-material\": \"^5.14.13\",\n\"@mui/material\": \"^5.14.13\",\n\"react\": \"^18.2.0\",\n\"react-dom\": \"^18.2.0\"\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furfdvw%2Freact-local-file-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furfdvw%2Freact-local-file-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furfdvw%2Freact-local-file-system/lists"}