본문 바로가기
Program/React

[next.js] version 13, head.js

by pishio 2023. 1. 2.

In the pages directory, the next/head React component is used to manage <head> HTML elements such as title and meta . In the app directory, next/head is replaced with a new head.js special file.

Before:

pages/index.tsx
import Head from 'next/head'

export default function Page() {
  return (
    <>
      <Head>
        <title>My page title</title>
      </Head>
    </>
  )
}

After:

app/head.tsx
export default function Head() {
  return (
    <>
      <title>My Page Title</title>
      <meta name="viewport" content="width=device-width, initial-scale=1"  />
    </>
  )
}

댓글