Chapter 18 of 21
Continue learning Next.js step by step.
Database Integration
Learn how Next.js applications can work with databases.
Theory
Next.js can be used with databases to build full-stack applications.
Server-side code can communicate with databases to read and write application data.
Popular choices include PostgreSQL, MySQL, MongoDB and other database systems.
Example
const users = await db.user.findMany();
console.log(users);Output
The application retrieves user records from the database.
Practice
Connect a Next.js application to a database and fetch records.
Interview Questions
1
Can Next.js connect to a database?
2
Why should database operations generally run on the server?
3
What is ORM?
Quick Quiz
Which option best describes this chapter?
A.PostgreSQL
B.CSS
C.HTML
D.Tailwind class