0

Is there any way to keep an object and its content on API side in nextJs?

I want to have a singleton and use it in all my requests. but when I importing create a new instance for each request.

Behnam Azimi
  • 2,260
  • 3
  • 34
  • 52
  • Do something like this - https://github.com/vercel/next.js/blob/canary/examples/with-mongodb/lib/mongodb.js – brc-dd Nov 03 '21 at 19:28

1 Answers1

0

You can use Symbol.for and the Node global to mantain an instance saved somewhere in the server.