리액트 라우터 용어
/user/123
은 2개의 segment를 가지고 있다. user와 123("/users/:userId")
또는 Star segment("/docs/*")
와 같은 특수 문자가 있을 수 있음<Route path element>
형태 객체, path가 일치하면 element 렌더{
pathname: "/bbq/pig-pickins",
search: "?campaign=instagram",
hash: "#menu",
state: null,
key: "aefz24ie"
}
지정된 매개변수에 값을 할당
// given a location like this:
let location = {
pathname: "/bbq/pig-pickins",
search: "?campaign=instagram&popular=true",
hash: "",
state: null,
key: "aefz24ie"
};
// we can turn the location.search into URLSearchParams
let params = new URLSearchParams(location.search);
params.get("campaign"); // "instagram"
params.get("popular"); // "true"
params.toString(); // "campaign=instagram&popular=true",
현재 페이지 scroll position 표시에 사용
url에 보이지 않는 값들
하위 컴포넌트에 데이터 전달 가능
각각의 location은 unique key를 가진다
location based scroll management, client side data caching 등에 유용하다
직관적인 페이지 기반 라우팅 시스템
페이지별 Pre-rendering, Static Site Generation, Server Side Rendering
빠른 페이지 로드를 위한 자동 코드 스플리팅
최적화된 prefetching 과 Client side routing
Sass 제공, css in js 라이브러리도 사용 가능
Fast Refresh 지원
serverless function으로 API endpoint 빌드 할 수 있는 API routes 제공
확장 가능
현재 learn basics navigate beween pages까지 진행 assets, metadata, and css 공부 할 차례
Assets, Metadata, and CSS
The second page we added currently does not have styling.
Let's add some CSS to style the page.
NExt.js has built-in support for CSS and Sass.
For this course, we will use CSS.
This lesson will also talk about how Next.js handles static assets like images and page metadata like the <title>
tag
What you'll learn in this lesson
how to add static files (images, etc) to Next.js
How to customize what goes inside the <head>
for each page.
How to create a reusable React component which is styled using CSS Modules.
How to add global CSS in pages/_app.js
.
Some useful tips for styling in Next.js
Prerequisites
Basic CSS knowledge. This course will go over how to add CSS in a Next.js app, but it won't cover CSS fundamentals.
If you're looking for detailed documentation on Next.js styling, take a look at the CSS documentation.
Next.js는 정적 자원들, 이미지 같은 것들을 top-level 'public' 디렉토리에 지원.
img tag 대신 최적화된 Image 컴포넌트를 사용