title: Where do I connect my mongodb Atlas to my react app?
body: <p>I am building a React app with node.js with mongodb Atlas database. I have created the mongodb Atlas cluster and need to connect it to the React app. The mongodb documentation  says to use this code </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var MongoClient = require('mongodb').MongoClient;
  
  var uri = "mongodb+srv://kay:myRealPassword@cluster0.mongodb.net/test";
  MongoClient.connect(uri, function(err, client) {
     const collection = client.db("test").collection("devices");
     // perform actions on the collection object
     client.close();
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>But - I'm not exactly sure where in my React app it should go. I am using react-router-dom and most places I put it breaks the app. Any ideas?</p>