Next.js API: Connect to MySQL Database
Published in
10 min readOct 24, 2023
Next.js is a React framework that can be used to build static and dynamic websites and web applications. It is known for its performance, SEO, and scalability.
In this article, we will talk about:
∘ Setting up MySQL Server Locally
∘ REST API
∘ Create Next.js app
∘ Create an API
∘ Installing mysql2 library
∘ Environment Variables
∘ Using mysql2 and running a query…