0

The NextJs tutorial sets up a blog that uses pre-rendering via static generation to read data dependencies (blog posts, in this case) from markdown files, sending this data as props to the page. Very neat!

I went to build upon this by adding the ability to edit the markdown on the page. After implementing said editability I aimed to persist the changes, but I reached a blocking error message saying 'fs' can't be resolved. It then hit me that I am trying to execute some server-side code (saving markdown to files) from the client.

What options do I have to save markdown from the client?

juancho
  • 79
  • 9
  • 1
    Move the logic to access and manipulate the file to an API route (server-side), then make a request from the client to that same API route to make the changes. – juliomalves Feb 27 '22 at 15:15
  • @juliomalves this can be done within the same nextjs app? so it acts as a front-end (consumes post crud api) and back-end (exposes post crud api) as the same time? – juancho Mar 10 '22 at 10:49
  • 1
    Yes, it can indeed. – juliomalves Mar 10 '22 at 10:52

0 Answers0