Next.js Discord

Discord Forum

How to and should I reuse an SDK client between different API routes?

Unanswered
Bonga shad posted this in #help-forum
Open in Discord
Avatar
Bonga shadOP
I am using an Node SDK client for Brevo inside of my api routes. I have different routes responsible for handling sending different email. I am wondering if I can and if it is a good practise to reuse a Brevo client between those routes or just create client each time the endpoints are called.

1 Reply

Avatar
I believe it is common practice to create a single instance of something will be shared across the whole NextJS project. things like prisma, drizzle, stripe, or anything really, they tend to be stored as a global instance in a single file