Ok. Like @khokon said, for that you'd need a server. Do you already run your React app on a local server?
Personally, I usually go for something like Next.js instead, which lets you use serverless API functions, it makes it very easy to add some nodejs "glue code" to a react project.
Storing files might not be a great fit for that, if it's possible I would recommend saving your JSON data on a server instead. It's very easy to get started with for instance Redis with a library like node-redis or ioredis in Next.js, and with a service like Upstash you can do that for free.
There are more solutions for databases specifically targeting serverless available for free or very cheap, like MongoDB or CockroachDB.
I suggest you take a look at some databases first, in the end it might be a lot easier to deploy. I hope this helped!
What exactly do you want to accomplish?
i want to create react app and i use fs.writeSync
Yes, but what kind of file do you want to write, and why? Maybe writeSync isn't the solution.
i want to save data in the form of json file in local
Ok. Like @khokon said, for that you'd need a server. Do you already run your React app on a local server?
Personally, I usually go for something like Next.js instead, which lets you use serverless API functions, it makes it very easy to add some nodejs "glue code" to a react project.
Storing files might not be a great fit for that, if it's possible I would recommend saving your JSON data on a server instead. It's very easy to get started with for instance Redis with a library like node-redis or ioredis in Next.js, and with a service like Upstash you can do that for free.
There are more solutions for databases specifically targeting serverless available for free or very cheap, like MongoDB or CockroachDB.
I suggest you take a look at some databases first, in the end it might be a lot easier to deploy. I hope this helped!
thanks Emmie Paivarinta