title: Next.js API and DB Connections Issue
body: <p>Should I reconnect to the DB in every handler when I use next.js for API?
  Or is there a better way to do that?</p>
  <p>And isn't that a bad thing if it was the regular approach?</p>
  <p>I tried to create a nextjs project with <strong>typeorm</strong> or <strong>MongoDB</strong> and all the examples and resources look like they are waiting for the connection with each call.
  <a href="https://i.stack.imgur.com/bvZAm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bvZAm.png" alt="enter image description here" /></a></p>
  <p>The attached image is for <strong>typeorm</strong> example. I got it from this <a href="https://github.com/mthomps4/next-now-test/tree/next-typeorm-example" rel="noreferrer">repo</a></p>
  <p>And here is the Mongo articles that I found that they instruct to add the DB connection in middleware and recall it in every handler.</p>
  <p><a href="https://developer.mongodb.com/how-to/nextjs-building-modern-applications" rel="noreferrer">https://developer.mongodb.com/how-to/nextjs-building-modern-applications</a>
  <a href="https://hoangvvo.com/blog/full-fledged-app-with-next-js-and-mongodb-part-1/" rel="noreferrer">https://hoangvvo.com/blog/full-fledged-app-with-next-js-and-mongodb-part-1/</a></p>
  <p>and here is the repos middleware to check it too if you like</p>
  <p><a href="https://github.com/kukicado/building-modern-app-with-nextjs-and-mongodb/blob/master/mct/middleware/database.js" rel="noreferrer">https://github.com/kukicado/building-modern-app-with-nextjs-and-mongodb/blob/master/mct/middleware/database.js</a></p>
  <p><a href="https://github.com/hoangvvo/nextjs-mongodb-app/blob/master/middlewares/database.js" rel="noreferrer">https://github.com/hoangvvo/nextjs-mongodb-app/blob/master/middlewares/database.js</a></p>
  <p>For me am trying to create nextjs with typeorm but I searched for the Mongo because I couldn't find a lot of resources for typeorm + nextjs so I searched for the connection concept for the Monog since it's kinda similar</p>