Next.js - Layout, Template, Page, Route, Link
- Link
- 기본 형태 <Link href=”…”>button</Link>
- ex) <Link href=”/” scroll={false} type=”button”>Home</Link>
- a tag는 자동 생성
- 기본 형태 <Link href=”…”>button</Link>
- useRouter
- import { useRouter } from 'next/navigation';
- const router = useRouter();
- usePathname
- import { usePathname } from 'next/navigation’;
- const pathname = usePathname();
- redirect
- import { redirect } from 'next/navigation’;
- if (…) redirect('/login');
Next.js - Routes
- Dynamic Routes
- Nested Dynamic Routes
- /shop/[…slug]: /shop/page.tsx
- /shop/[[…slug]]: /shop/[[…slug]/page.tsx
- @parallel Routes
- Intercepting Routes
- client router와 server router를 다르게 표현
- A → B(intercept) → B(refresh)
'Front-end > Next.js' 카테고리의 다른 글
[Next.js] Server API, middleware (0) | 2024.03.08 |
---|---|
[Next.js] Styling (shadcn/ui 사용) (0) | 2024.03.08 |
[Next.js] Data Fetching (0) | 2024.03.08 |
[Next.js] Project 생성 및 설정 (0) | 2024.03.08 |
[Next.js] Next.js 시작하기 (0) | 2024.03.08 |