useFs
Sandboxed file read/write, scoped by the fs config in registerNextOP.
All hooks are imported from the package root. Every hook is safe to call during SSR / on the web —
it no-ops or returns null when window.desktop is unavailable.
const { readFile, writeFile } = useFs()
| Member | Type | Notes |
|---|---|---|
readFile | (filePath: string) => Promise<string | null> | UTF-8. Returns null if desktop API absent. |
writeFile | (filePath: string, content: string) => Promise<boolean | null> | UTF-8. Resolves true on success. |
import { useFs } from 'nextop-app'const { readFile, writeFile } = useFs()await writeFile('notes.txt', 'hello from NextOP')const contents = await readFile('notes.txt')
Path resolution & traversal protection are governed by fs.mode / fs.allowedRoots
(see the Security Model). Relative paths resolve against the first allowedRoot.