Course Content
Next.js 14 Mastery for Building Modern Web Apps
Next.js 14 Mastery for Building Modern Web Apps
1. Introduction to Next.js
2. Setting Up a Next.js Project
Setting Up the Next.js Project Understanding the Project File and Folder StructureStyling Approaches in Next.jsAdding the Global CSS FileUsing Tailwind CSS for StylingWorking with CSS ModulesApplying Styles ConditionallyAdding Custom Google FontsChallenge: Implementing a Custom Google FontHandling Images in Next.js
3. Building Pages and Layouts in Next.js
4. Deploying a Next.js App and Setting Up a Database
5. Fetching and Displaying Data in Next.js
6. Advanced Next.js Features and Optimizations
7. Implementing Authentication in Next.js
Understanding AuthenticationSetting Up the Login RouteUsing NextAuth.js for AuthenticationConfiguring Authentication and Protecting RoutesHashing Passwords and Managing CredentialsImplementing Sign-In FunctionalityConnecting the UI with Authentication LogicImplementing Logout FunctionalityFinal Thoughts and Next Steps
How to Fetch Data in Next.js
Let's discuss the different methods of retrieving data in Next.js.
API Layer
An API layer acts as a bridge between your application code and the database. You might consider using an API in the following situations:
- Third-party Services: If you're integrating 3rd party services that offer an API;
- Client-Side Data Fetching: When fetching data from the client, it's crucial to have an API layer on the server. This helps in keeping your database secrets secure, preventing exposure to the client.
Database Queries
In a full-stack application, you'll also need to handle interactions with your database. For relational databases like Postgres, you can accomplish this using SQL or an ORM like Prisma. Cases where you need to write database queries include:
- API Endpoint Creation: When developing your API endpoints, you must write logic to interact with the database;
- React Server Components: If you're using React Server Components and fetching data on the server, you can bypass the API layer. This allows you to query your database directly without risk exposing sensitive information to the client.
In our Project
We will use SQL with the Vercel Postgres SDK for a few reasons:
- SQL is the standard for querying relational databases;
- Learning SQL helps you understand the basics of databases, applicable to various tools;
- SQL is versatile for fetching and manipulating specific data;
- The Vercel Postgres SDK protects against SQL injections, ensuring secure queries.
Everything was clear?
Thanks for your feedback!
Section 5. Chapter 1