NeonN
Neon15mo ago
1 reply
instant-harlequin

Nextjs server actions: best way to connect?

Hi, sorry for this question as I'm a complete beginner. As I was going through the docs, I noticed there's nothing about setting up a global variable to initiate a connection pool (like you would with PrismaClient()) and then reusing it throughout your logic. Do I need to use const sql = neon(process.env.DATABASE_URL) in every server action where I want to interact with the database? It seems to me this would open a new connection each time, so I’m wondering if there’s a better way to handle this.
Was this page helpful?