title: NextJS form to send data to MongoDB
body: <p>I'm new to JavaScript, know the basics and lack experience, but I want to learn more.
  I created a project using NextJS, which is a light framework that works with ReactJS, and what I am struggling to understand is how can I create a simple form, with one field where you enter data and once clicked on submit, the data to be sent over to a MongoDB collection.</p>
  <p>I managed to connect the project to a MongoDB database and by accessing a page to make it return some data from a collection, but I'm trying to understand the structure of how can I do this, to send the data to a collection.</p>
  <p>Do I have to somehow make one js file to reference another js file where I have the MongoDB configuration and make use of the connectToDatabase function and send the submit data via a simple insertOne query within the js file? Or do I have to send the data to another js file where I have some sort of API configuration and do a POST?</p>
  <p>If you could advise on how can I achieve this, it would be much appreciated. Even with an article or anything that could help me better understand the structure behind.</p>
  <p>Thank you.</p>