SitePoint
Blog
Forum
Library
Login
Join Premium
Toggle sidebar
Real-World Next.js
Toggle community discussions
Close
Content
Files
Bookmarks
Preface
Real-World Next.js
Contributors
About the author
About the reviewers
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Share Your Thoughts
1
A Brief Introduction to Next.js
Part 1: Introduction to Next.js
Technical requirements
Introducing Next.js
Comparing Next.js to other alternatives
Gatsby
Razzle
Nuxt.js
Angular Universal
So, why Next.js?
Moving from React to Next.js
Getting started with Next.js
Default project structure
TypeScript integration
Custom Babel and webpack configuration
Summary
Exploring Different Rendering Strategies
Technical requirements
Server-side rendering (SSR)
Client-side rendering (CSR)
Using the React.useEffect hook
Using the process.browser variable
Using dynamic component loading
Static site generation
Summary
Next.js Basics and Built-In Components
Technical requirements
Routing system
Using route variables inside our pages
Using route variables inside components
Client-side navigation
Serving static assets
Next.js' automatic image optimization
Running automatic image optimization on external services
Handling metadata
Grouping common meta tags
Customizing _app.js and _document.js pages
The _app.js page
The _document.js page
Summary
Organizing the Code Base and Fetching Data in Next.js
Part 2: Hands-On Next.js
Technical requirements
Organizing the folder structure
Organizing the components
Organizing utilities
Organizing static assets
Organizing styles
Lib files
Data fetching
Fetching data on the server side
Consuming REST APIs on the server side
Fetching data on the client side
Consuming REST APIs on the client side
Consuming GraphQL APIs
Summary
Managing Local and Global States in Next.js
Technical requirements
Local state management
Global state management
Using the Context APIs
Using Redux
Summary
CSS and Built-In Styling Methods
Technical requirements
Exploring and using Styled JSX
CSS modules
Integrating SASS with Next.js
Summary
Using UI Frameworks
Technical requirements
An introduction to UI libraries
Integrating Chakra UI in Next.js
Building an employee directory with Chakra UI and Next.js
Conclusive words about Chakra UI
Integrating TailwindCSS in Next.js
Integrating Headless UI
Summary
Using a Custom Server
Technical requirements
About using a custom server
Using a custom Express.js server
Using a custom Fastify server
Summary
Testing Next.js
Technical requirements
An introduction to testing
Running unit and integration tests
End-to-end testing with Cypress
Summary
Working with SEO and Managing Performance
Technical requirements
SEO and performance – an introduction
Rendering strategies, from a performance and SEO perspective
The reasoning behind a real-world website example
Rendering the image detail page
Private routes
A quick recap regarding our decisions
Working with SEO
Dealing with performance
Summary
Different Deployment Platforms
Technical requirements
A brief introduction to different deployment platforms
Deploying to the Vercel platform
Deploying a static site to a CDN
Choosing a CDN
Deploying Next.js on any server
Running Next.js in a Docker container
Summary
Managing Authentication and User Sessions
Part 3: Next.js by Example
Technical requirements
A brief introduction to user sessions and authentication
Understanding JSON web tokens
Custom authentication – the good, the bad, and the ugly
Implementing authentication using Auth0
Customizing Auth0
Summary
Building an E-Commerce Website with Next.js and GraphCMS
Technical requirements
Creating e-commerce websites for the modern web
Setting up GraphCMS
Creating the storefront, cart, and product detail pages
Processing payments using Stripe
Summary
Example Projects and Next Steps for Learning More
One framework, endless possibilities
Real-world applications for practicing with Next.js
Streaming website
Blogging platform
Real-time chat website
Next steps
Summary
Open text modal
Community Questions
Close