FileWriting React



I was working on a little in house React page that allows the user to load a file and do some modifications.

Is it possible to have the data then saved to directory I’m running react out of? All I have seen online is simulating a “download” file function.

I would want similar things for larger projects to record log files, etc.

Any suggestions would be great.



On the client side, you can’t arbitrarily save files to the local file system. You can use the File API to launch a save dialog if that works for you. Otherwise you’ll need to have your backend (server) handle that. But that also means saving to the server vs the local file system (unless they’re one in the same), which I’m assuming is what you want since you said from the directory you’re running react.

Kirupa has some tutorials around this, but I think they look all to be pretty old, and I’m pretty sure there’s nothing react-specific (though react isn’t really at play for these kinds of things). You might be better off googling the details.


I would only want to save to the server (which I am working on anyway). If someone else runs the page I would not want anything saved to their client.