1. Next.js๋ ๋ฌด์์ธ๊ฐ?
React: UI ๋ผ์ด๋ธ๋ฌ๋ฆฌ (CSR ์ค์ฌ)
Next.js: React ๊ธฐ๋ฐ ํ์คํ ํ๋ ์์ํฌ
โ SSR/SSG ์ง์, ํ์ผ ๊ธฐ๋ฐ ๋ผ์ฐํ , API, SEO ์ต์ ํ, Vercel ๋ฐฐํฌ
2. ๊ฐ๋ฐ ํ๊ฒฝ ์ค๋น
(1) Node.js ์ค์น ํ์ธ
node -v
npm -v
โ Node.js 18 ์ด์ ๊ถ์ฅ
(2) Next.js ํ๋ก์ ํธ ์์ฑ
npx create-next-app@latest next-tutorial
cd next-tutorial
npm run dev
โ ๋ธ๋ผ์ฐ์ http://localhost:3000
์ ์ โ Next.js ๊ธฐ๋ณธ ํ๋ฉด ํ์ธ
3. SCSS ์ค์น
npm install sass
โ ์ด์ *.module.scss
ํ์ผ์ ๋ง๋ค ์ ์์
4. ๊ธ๋ก๋ฒ ํฐํธ(Noto Sans KR) ์ ์ฉ
Next.js 13 ์ด์์์๋ next/font๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ๊ฐ์ฅ ๊น๋ํฉ๋๋ค.
Google Fonts์์ ์ง์ ๋ถ๋ฌ์ฌ ์ ์์ด์.
(1) app/layout.tsx
์์
import './globals.css';
import { Noto_Sans_KR } from 'next/font/google';
const notoSansKR = Noto_Sans_KR({
subsets: ['latin'],
weight: ['400', '500', '700'],
});
export const metadata = {
title: 'My Next.js App',
description: 'Next.js ๊ธฐ์ด ๊ฐ์ข ํ๋ก์ ํธ',
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="ko">
<body className={notoSansKR.className}>{children}</body>
</html>
);
}
๐ ์ด๋ ๊ฒ ํ๋ฉด ์ ์ฒด ํ๋ก์ ํธ์ ๊ธฐ๋ณธ ํฐํธ๊ฐ Noto Sans KR๋ก ์ง์ ๋ฉ๋๋ค.
5. SCSS ๋ชจ๋ ์ ์ฉ
(1) styles/home.module.scss
.title {
font-size: 2rem;
color: #0070f3;
text-align: center;
margin-top: 2rem;
}
.description {
color: #555;
text-align: center;
font-size: 1.2rem;
}
(2) app/page.tsx
import styles from "../styles/home.module.scss";
export default function Home() {
return (
<main>
<h1 className={styles.title}>Hello Next.js ๐</h1>
<p className={styles.description}>
์ด๊ฒ์ด ๋์ ์ฒซ ๋ฒ์งธ Next.js + SCSS + Noto Sans KR ํ์ด์ง์
๋๋ค.
</p>
</main>
);
}
6. ์ค๋์ ์ ๋ฆฌ
- Next.js ํ๋ก์ ํธ ์์ฑ (
create-next-app
) - SCSS ์ค์น ๋ฐ ๋ชจ๋ ์คํ์ผ ์ ์ฉ
- ๊ธ๋ก๋ฒ ํฐํธ(Noto Sans KR) ์ ์ฉ โ
layout.tsx
์ ์ ์ญ ์ธํ - ๊ธฐ๋ณธ ํ์ด์ง ์คํ์ผ ์์ฑ ๐
๐ฌ ๋๊ธ
โป ๋ก๊ทธ์ธ ํ ๋๊ธ์ ์์ฑํ ์ ์์ต๋๋ค.