Next.js는 root directory에서 public
폴더 아래에서 이미지와 같은 static file을 제공할 수 있다.
pubilc 안의 파일은 base URL /
로 시작하여 코드에서 참조할 수 있다.
Note: next/image requires Next.js 10 or later.
import Image from 'next/image'
function Avatar() {
return <Image src="/me.png" alt="me" width="64" height="64" />
}
export default Avatar
이 폴더는 또한 robots.txt, favicon.ico 등등 static 파일들에도(.html 포함) 유용하다.
주의할 점은, public 이름 이외의 다른 이름으로는 지정할 수 없다.
onClick
을 사용할 수 없다.<html>
, <head />
, <main />
및 <nextscript />
는 페이지가 올바르게 렌더링 될 때 필요하다.<Html lang="en">
...
<body className="bg-white">
_document
에서 사용되는 <Head />
는 next/head
로서 사용되는 <Head />
와 동일하지 않다,_app.js
에 추가하도록 한다