How to Integrate Vercel & MongoDB Step-by-Step

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ธ.ค. 2024

ความคิดเห็น • 50

  • @MongoDB
    @MongoDB  2 ปีที่แล้ว +1

    ✅ Create a new Vercel project: bit.ly/vercel-mdb
    ✅ Sign-up for a free cluster at: mdb.link/free-JIlYroSsInU
    ✅ Get help on our Community Forums: mdb.link/community-JIlYroSsInU

  • @Dilchaspian
    @Dilchaspian 11 หลายเดือนก่อน +5

    I rewrote code in js, from ts example i got, it is working in production mode on vercel, mongoDb is connecting successfully. But in Development its not, i have pulled env from vercel too, but it simply dont work

  • @Dilchaspian
    @Dilchaspian 11 หลายเดือนก่อน +3

    Why it have typescript? Not in tutorial u get js files, we are now getting Ts FIles

  • @guilherme1260
    @guilherme1260 ปีที่แล้ว

    Thank you very much!!! After spend 6 hours i finally did my server!!!

  • @joaobraganca6011
    @joaobraganca6011 2 ปีที่แล้ว +2

    Amazing video! Thank you so much for the detailed explanation!

  • @MuseCraftman
    @MuseCraftman 9 วันที่ผ่านมา +1

    Thank you!

    • @MongoDB
      @MongoDB  8 วันที่ผ่านมา

      Any time!!

  • @bananalabo
    @bananalabo ปีที่แล้ว +5

    @MongoDB can you please update this video?

  • @MartinZazpe
    @MartinZazpe ปีที่แล้ว +2

    Don't you feel it's funky to have the front-end directly affect the database without some type of API?
    I thought a better approach to connect the React front-end to some backend (like node) and then let node deal with the HTTP requests.
    I don't use Next or mongo regularly, hence why I have this doubt.

  • @xx-fw1yq
    @xx-fw1yq ปีที่แล้ว +2

    If I want to host my project on Vercel and make it available to my users I should make my cluster whitelist ips list available to everyone?

  • @M_code_H
    @M_code_H 5 หลายเดือนก่อน +1

    thank you so much for clarification i will learn more about this stack

    • @MongoDB
      @MongoDB  5 หลายเดือนก่อน

      Very welcome

  • @abrarhussain_00
    @abrarhussain_00 ปีที่แล้ว +1

    this is done in next framework, however I am using cra. I am not having the same options. How would I deploy my server in vercel with react?

  • @mphatsomtogolo6263
    @mphatsomtogolo6263 ปีที่แล้ว +1

    How can I do the same without using TypeScript?

  • @Preshdev
    @Preshdev 2 ปีที่แล้ว +2

    you are doing a tutorial without a link to the source code, its really stressful bruv, thanks anways

    • @MongoDB
      @MongoDB  2 ปีที่แล้ว +2

      Hi Omezi, here are links to the written tutorials:
      - bit.ly/3djh7fL
      - bit.ly/3vNFzw4

  • @shababsaami96
    @shababsaami96 ปีที่แล้ว

    What if I were to add mongo to an existing project? Would i just " npm i mongodb" and use the library as shown in the video or do i need to do more configuration?

    • @hehimselfishim
      @hehimselfishim ปีที่แล้ว

      my question too, i already have an existing nextjs project.

  • @pilicod1334
    @pilicod1334 2 หลายเดือนก่อน +1

    its helpfull , must integrate mongodb in vercel , not manually input it .env mong uri

    • @MongoDB
      @MongoDB  2 หลายเดือนก่อน

      Thanks!

  • @sankar_royals
    @sankar_royals 2 ปีที่แล้ว

    Is this same process for django project to connect mongodb in vercel?

  • @floriang.5794
    @floriang.5794 ปีที่แล้ว

    Dont know why but I followed your video and the sample code from Max for mongoose setup, but despite that the log prints message on each page refresh

  • @ButterDog11
    @ButterDog11 2 วันที่ผ่านมา

    Integrating vercel with atlas just takes too long for me, more than 10 mins +. Is this normal? It doesn't integrate properly

  • @GoodbyeMrX
    @GoodbyeMrX 8 หลายเดือนก่อน

    The command "vercel" won't be recognized. Open cmd and enter: npm install -g vercel
    After that vercel command worked for me.

  • @cetinsss
    @cetinsss ปีที่แล้ว

    I've tried to remove -y but ended up with TS version anyway. Is there a method to set up this template in JS? So far I've tried to add --js to the command and tsc command but didn't worked.

    • @adornnet
      @adornnet ปีที่แล้ว +1

      have you tried replace the -y with -n ? If still not working, add additional --js after the -n

    • @cetinsss
      @cetinsss ปีที่แล้ว

      @@adornnet I didn't tried -n before, thanks. But in this case it didn't worked because the template doesn't have js version. I wish I would learn ts but I've got a lot in my plate at the moment.

    • @mphatsomtogolo6263
      @mphatsomtogolo6263 ปีที่แล้ว

      @@cetinsss Got the same problem here. So this project wont work without TS?

    • @cetinsss
      @cetinsss ปีที่แล้ว

      @mphatsomtogolo6263 Unfortunately, it won't. But vercel is constantly updating their template apps on their website. You can check for other templates with js if you need a starter template to practise. Hope this helps

  • @ariobotgaming
    @ariobotgaming ปีที่แล้ว +1

    well this is hard to follow without nextjs, I am using vite+react

  • @qxb348
    @qxb348 2 ปีที่แล้ว

    is it the same for mongoose?

    • @jewelzelal
      @jewelzelal 2 ปีที่แล้ว +1

      may be, I am trying with mongoose

    • @lscodeschool957
      @lscodeschool957 2 ปีที่แล้ว

      @@jewelzelal How far with this
      I am having a serverless function timedout using mongoose

    • @adocarpel7770
      @adocarpel7770 ปีที่แล้ว

      I try with nodejs and monggose but
      404: NOT_FOUND
      Code: NOT_FOUND
      ID: iad1::6sgv9-1673356691534-de855ad4e4b2

  • @janoskukoda3979
    @janoskukoda3979 2 ปีที่แล้ว

    It does not create for me MONGODB_URI in Vercel?!

  • @diogo1277
    @diogo1277 5 หลายเดือนก่อน

    why this cors is so difficult, I just want to continue working on something else

    • @MongoDB
      @MongoDB  5 หลายเดือนก่อน

      cors is very important for website security. Is there something specific you would like to learn about it?

  • @sanalms1601
    @sanalms1601 9 หลายเดือนก่อน

    your amazing👍👍

  •  ปีที่แล้ว +2

    comand vercel is not recognized after installing vercel
    this video should be outdated

  • @maxvhanamane840
    @maxvhanamane840 2 ปีที่แล้ว +2

    Here is how you make a cached connection using mongoose. See replies on this comment.

    • @maxvhanamane840
      @maxvhanamane840 2 ปีที่แล้ว

      I found one way to cache MongoDB connection using mongoose.... I will add that here later...

    • @lscodeschool957
      @lscodeschool957 2 ปีที่แล้ว

      @@maxvhanamane840 Can we see what you have with mongoose

    • @maxvhanamane840
      @maxvhanamane840 2 ปีที่แล้ว +1

      @@lscodeschool957 sure. here is the code. It worked for me. I tried adding console logs to test wheather it is using cached connection or it is making a new connection every time and indeed it was using cached connection. I know the code looks little weird but it works.
      import mongoose from 'mongoose'
      const MONGODB_URI = process.env.MONGO_URI
      // If MongoDb uri is not provided we will throw an error
      if (!MONGODB_URI) {
      throw new Error(
      'Please define the MONGODB_URI environment variable inside .env.local'
      )
      }
      // When we first connect to the db we will cache that connection in a variable named cached so that we don't have to connect to the database again and again on each and every request.
      let cached = global.mongoose
      // If we don't have cached connection then first we will set conn: null, promise: null
      if (!cached) {
      cached = global.mongoose = { conn: null, promise: null }
      }
      // creating an async function to connect to the db
      async function connectDb() {
      // If we have cached connection then we don't have to make connection once again. we will return the old connection.
      if (cached.conn) {
      return cached.conn
      }
      // If we don't have cached connection then we will create one and return it.
      if (!cached.promise) {
      const opts = {
      bufferCommands: false,
      }
      cached.promise = await mongoose.connect(MONGODB_URI, {useNewUrlParser: true}).then((mongoose) => {
      return mongoose
      })
      }
      try {
      cached.conn = await cached.promise
      } catch (e) {
      cached.promise = null
      throw e
      }
      return cached.conn
      }
      export default connectDb

    • @lscodeschool957
      @lscodeschool957 2 ปีที่แล้ว

      @@maxvhanamane840 Ok I will try it in my code and get back with some findings if it has worked

    • @lscodeschool957
      @lscodeschool957 2 ปีที่แล้ว

      @@maxvhanamane840 Cool it has worked .... Thanks

  • @nightmoves
    @nightmoves 11 หลายเดือนก่อน +1

    this one still uses pages router

  • @ardit2705
    @ardit2705 2 ปีที่แล้ว

    🇽🇰 👋

  • @adocarpel7770
    @adocarpel7770 ปีที่แล้ว

    Many thanks. I try with nodejs but 404: NOT_FOUND
    Code: NOT_FOUND
    ID: iad1::6sgv9-1673356691534-de855ad4e4b2