How to Save User Input and How to Store it in a Database

Hi, I’m new to codemirror and I am trying to integrate it in my web application. I’m using react version 17. How would I save the user input, and hook it up to a button so when they click it, it sends the code input to be stored in a database. Also, would I store the input in a string, or does codemirror have a clever way of organizing the input?

Thank you!

By “input” do you mean the typed document? You can get that from view.state.doc.toString().