Why don't we add MongoDB integration in Vercel?

Idea

I was usually using MongoDB for my project in the past. But recently, I felt that MongoDB doesn’t interact with Next.js server functions in Vercel. It was working well on my local but if it is deployed on Vercel and as many as users are using it, it causes runtime error.
so I started integrating PostgreSQL like NeonDB in Vercel.
I am not sure that’s why Vercel doesn’t support MongoDB integration but I think this problem should be solved finally.
Thanks Vercel team.

You can use MongoDB like any other DB in your Next.js backend. There does not have to be a official Vercel integration for it to work. We use an AWS RDS :man_shrugging: Vercel integrations are just an convenience method to setup dependencies. Just add your Mongo connection to the environment variables and you’re ready to go.

Thanks for your reply.
So I made my project using serverless function with mongodb but it causes runtime errors sometimes when many users are visiting website.
So I had to move the backend to express.js.
I think next.js backend is not interacting well with mongodb.
Am I wrong?

There are a dozen details missing. The more information you share about your code / architecture the better someone can help.

1 Like


This is one of my server actions code.
In normal case, it’s okay but it’s causing stream connection error with MongoDB if many users are running this kind of request at same time.