Course Content
Subtitle Guide – Hướng dẫn thêm phụ đề
0/1
02 – Optional React Refresher
0/77
03 – NextJS Essentials (App Router)
0/49
15 – Optional NextJS Summary
0/37
16 – Course Roundup
0/1
Next.js 14 & React – The Complete Guide
About Lesson

In this course, we always close our MongoDB connections via client.close().

This works and you can do that.

If you build an application where your MongoDB-related code will execute frequently (e.g. the API route will be hit frequently), you might want to take advantage of MongoDB’s “connection pooling” though.

For this, simply remove all client.close() calls from your code. The connection will then NOT be closed and will be re-used across requests.