---
title: "Comment by Next Dev on \"🗃️ How to use Mongoose with Next.js for MongoDB?\" | Hashnode"
description: "Won&#39;t it take time for the server to first connect to the Mongodb server and then fetch data. Is there any way by which we are connected to the Mongodb serv"
url: "https://hashnode.com/posts/how-to-use-mongoose-with-nextjs-for-mongodb/625bd39852fb7bd53380fbd2/comment/63a3ba6df67b03c0a9633c5c"
---

[Discussion](https://hashnode.com/posts/how-to-use-mongoose-with-nextjs-for-mongodb/625bd39852fb7bd53380fbd2)

Comment [🗃️ How to use Mongoose with Next.js for MongoDB?](https://hashnode.com/posts/how-to-use-mongoose-with-nextjs-for-mongodb/625bd39852fb7bd53380fbd2)

[Next Dev](https://hashnode.com/@nextdev)

[Dec 22, 2022](https://hashnode.com/posts/how-to-use-mongoose-with-nextjs-for-mongodb/625bd39852fb7bd53380fbd2/comment/63a3ba6df67b03c0a9633c5c)

Won't it take time for the server to first connect to the Mongodb server and then fetch data.

Is there any way by which we are connected to the Mongodb server forever and when request will be sent to it. It just has to fetch the data and return to the nextjs server function.

[Usman Sabuwala](https://hashnode.com/@usmanwrites)

[Dec 22, 2022](https://hashnode.com/posts/how-to-use-mongoose-with-nextjs-for-mongodb/625bd39852fb7bd53380fbd2/comment/63a3ba6df67b03c0a9633c5c#reply-63a3bc84f7fa1fc0ce9eb6c5)

That's actually not possible due to the behaviour of API Routes in Next.js.

Next.js has API Routes and those are AWS Lambda functions. It's not a fully fledged backend and that's the reason we have to connect to Mongo everytime.

Watch this video, it explains how backend works in Next.js [youtu.be/Rrz2q5uCHdE](https://youtu.be/Rrz2q5uCHdE)
