Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Radheshyam Gupta
Radheshyam Gupta

Posted on

     

fs.writeSync

can i use fs.writeSync in react app,
please help me regarding this issue.

Thanks

Top comments(12)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
khokon profile image
Khokon M.
  • Joined

React is a client side application, and client side application can't access file system.

CollapseExpand
 
radhe65gupta profile image
Radheshyam Gupta
Software Developer
  • Location
    india
  • Education
    Master of Philosophy(IT)
  • Work
    Full Stack Developer
  • Joined

Please,can you help me regarding this?,

CollapseExpand
 
emmiep profile image
Emmie Päivärinta
  • Joined

What exactly do you want to accomplish?

Thread Thread
 
radhe65gupta profile image
Radheshyam Gupta
Software Developer
  • Location
    india
  • Education
    Master of Philosophy(IT)
  • Work
    Full Stack Developer
  • Joined

i want to create react app and i use fs.writeSync

Thread Thread
 
emmiep profile image
Emmie Päivärinta
  • Joined

Yes, but what kind of file do you want to write, and why? Maybe writeSync isn't the solution.

Thread Thread
 
radhe65gupta profile image
Radheshyam Gupta
Software Developer
  • Location
    india
  • Education
    Master of Philosophy(IT)
  • Work
    Full Stack Developer
  • Joined

i want to save data in the form of json file in local

Thread Thread
 
emmiep profile image
Emmie Päivärinta
  • Joined

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 useserverless 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 likenode-redis orioredis in Next.js, and with a service likeUpstash you can do that for free.
There are more solutions for databases specifically targeting serverless available for free or very cheap, likeMongoDB orCockroachDB.
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!

Thread Thread
 
radhe65gupta profile image
Radheshyam Gupta
Software Developer
  • Location
    india
  • Education
    Master of Philosophy(IT)
  • Work
    Full Stack Developer
  • Joined

thanks Emmie Paivarinta

CollapseExpand
 
khokon profile image
Khokon M.
  • Joined

You need to have a backend running using nodejs. Only then you can use the function

Thread Thread
 
radhe65gupta profile image
Radheshyam Gupta
Software Developer
  • Location
    india
  • Education
    Master of Philosophy(IT)
  • Work
    Full Stack Developer
  • Joined

can u share any reference?

CollapseExpand
 
radhe65gupta profile image
Radheshyam Gupta
Software Developer
  • Location
    india
  • Education
    Master of Philosophy(IT)
  • Work
    Full Stack Developer
  • Joined

hello

CollapseExpand
 
zabdeldjallil profile image
Djilou
Software engineer.Let's get in touch : djillou500@gmail.com
  • Location
    Algeria
  • Work
    Software engineer
  • Joined

Option 1:You can make a node js file in your react project then run a node ./nodescript.js in your hosting server.
Option 2: make a small node js server that you will send a request to from your react app (using fetch or axios)

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Software Developer
  • Location
    india
  • Education
    Master of Philosophy(IT)
  • Work
    Full Stack Developer
  • Joined

More fromRadheshyam Gupta

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp