Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Next.js Quick Start Guide

You're reading from   Next.js Quick Start Guide Server-side rendering done right

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher Packt
ISBN-13 9781788993661
Length 164 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Konshin Konshin
Author Profile Icon Konshin
Konshin
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
1. Introduction to Server-Side Rendering and Next.js FREE CHAPTER 2. Next.js fundamentals 3. Next.js Configuration 4. Next.js Data Flow 5. Application Life Cycle Handlers and Business Logic 6. Continuous Integration 7. Containers 1. Other Books You May Enjoy Index

Special pages


Next.js allows us to affect the way a website will be rendered by placing special handlers for certain items.

The first one is pages/_document.js, which allows us to define the surroundings of the page, such as the Head section. This could be useful to change the page title, add meta information or styles, and so on.

Here is a minimal example:

// pages/_document.js
import Document, {Head, Main, NextScript} from 'next/document';

export default class MyDocument extends Document {
render() {
return (
<html>
<Head>
<title>NextJS Condensed</title>
</Head>
<body>
<Main/>
<NextScript/>
</body>
</html>
        )
    }
}

In this example, we've configured the very basic surroundings of the actual markup that will be injected in the page straight in the body tag; also, we've added a title to the custom Head component.

The next special handler is pages/_app.js, which allows us to wrap ALL pages (including the error) in a special wrapper...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images