parallel Routes 는 더 진보된 라우팅 메커니즘으로, 하나의 레이아웃 안에 여러 페이지를 동시에 렌더링하는 것이다.

이렇게 하나의 레이아웃 안에 User analytics, Revenue metrics, Notifications 같은 여러 페이지를 렌더링 하는것이다.
Next.js에서는 Parallel Routes(병렬 경로)를 'slot'이라고 하는 기능을 사용하여 정의함, 슬롯은 내용을 모듈식으로 구조화하는 데 도움을 줌
병렬 경로는 일반적으로 다른 경로가 동시에 활성화 되어있을 때 사용되며, 이를 통해 다양한 섹션 또는 컴포넌트를 동시에 렌더링할 수 있음.
슬롯을 정의하기 위해 '@folder' 라는 명명 규칙을 사용함, 이는 특정 폴더나 경로를 참조할 때 사용되어지는 방식임
그리고 각 슬롯은 prop으로 해당 layout.js파일에 전달됨

이와 같은 구조임
// app/complex-dashboard/layout.js
export default function DashboardLayout({ children, users, revenue, notifications }) {
return (
<div>
<div>{children}</div>
<div style={{ display: 'flex' }}>
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div>{users}</div>
<div>{revenue}</div>
</div>
<div style={{ display: "flex", flex: 1 }}>{notifications}</div>
</div>
</div>
);
}
// app/complex-dashboard/@notification/page.js
import Card from "@/components/card"; // 스타일 컴포넌트
export default function Notifications() {
return<Card>Notifications</Card>
}
...
이와 같은 식으로 'slot' 개념을 사용하면 prop을 따로 정의하지 않아도 폴더 이름을 보고 알아서 인식하여 가져오게 됨

/complex-dashboard 페이지는 위와 같이 출력되게 됨







// app/complex-dashboard/layout.js
export default function DashboardLayout({ children, users, revenue, notifications, login }) {
const isLoggedIn = true
return isLoggedIn ? (
<div>
{/* app/complex-dashboard/@children/page.js */}
<div>{children}</div>
<div style={{ display: 'flex' }}>
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div>{users}</div>
<div>{revenue}</div>
</div>
<div style={{ display: "flex", flex: 1 }}>{notifications}</div>
</div>
</div>
) : (
login
);
}
이와 같이 layout.js로 login prop을 받아와 isLoggedIn이라는 불린값에 따라 login 페이지 혹은 기존의 complex-dashboard 페이지가 출력되게끔 하는 것이 가능함