We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
๐ ์ฃผ์ : React์ Next.js์ ์ฐจ์ด๋ฅผ ๋น๊ตํ๊ณ , Next.js๊ฐ ์ ๊ณตํ๋ ์ฃผ์ ๊ธฐ๋ฅ ๋ฐ ๊ฐ๋ ๋ค์ ์ ๋ฆฌํฉ๋๋ค.
๐ฏ ์คํฐ๋ ๋ชฉํ
๐ ํต์ฌ ๋ด์ฉ:
react-router
getServerSideProps
getStaticProps
next/image
Next.js๋ ๋ค์ํ ๋ ๋๋ง ๋ฐฉ์์ ์ง์ํ์ฌ ํ์ด์ง ์๊ตฌ์ฌํญ์ ๋ฐ๋ผ ํจ์จ์ ์ผ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
pages/index.js
/
pages/about.js
/about
pages/post/[id].js โ /post/1
Next.js๋ ์๋ฒ์ ํด๋ผ์ด์ธํธ ๋ชจ๋์์ ๋ฐ์ดํฐ๋ฅผ ํจ์นญํ ์ ์๋ ๋ด์ฅ ๋ฉ์๋๋ฅผ ์ ๊ณตํฉ๋๋ค.
getStaticPaths
/api/hello
// pages/api/hello.js export default function handler(req, res) { res.status(200).json({ message: 'Hello World!' }); }
dynamic import
import dynamic from 'next/dynamic'; const HeavyComponent = dynamic(() => import('../components/HeavyComponent'));
pages
api
public
my-next-app/ โโโ pages/ # ํ์ด์ง ์ปดํฌ๋ํธ โ โโโ index.js # ํ ํ์ด์ง โ โโโ about.js # About ํ์ด์ง โ โโโ api/ # API Routes โ โโโ hello.js # API ๋ผ์ฐํธ โโโ public/ # ์ ์ ํ์ผ (์ด๋ฏธ์ง, ํฐํธ ๋ฑ) โ โโโ favicon.ico # ํ๋น์ฝ โ โโโ logo.png # ๋ก๊ณ ์ด๋ฏธ์ง โโโ components/ # ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์ปดํฌ๋ํธ โ โโโ Navbar.js # ๋ค๋น๊ฒ์ด์ ์ปดํฌ๋ํธ โโโ styles/ # ์คํ์ผ ํ์ผ โ โโโ globals.css # ๊ธ๋ก๋ฒ ์คํ์ผ โ โโโ Home.module.css # ํน์ ํ์ด์ง ์คํ์ผ โโโ next.config.js # Next.js ์ค์ ํ์ผ
๐ก ์ฐธ๊ณ ์๋ฃ:
The text was updated successfully, but these errors were encountered:
React์ Next.js์ ์ฐจ์ด์ ์ ๋ํด ์๊ฒ๋์ด์ ์ข์์ต๋๋ค!
Sorry, something went wrong.
๊ธฐ์ ์คํ ์ ์ ์ ๋ง์์ ์ ๊ณ ๋ คํด์ next.js๋ฅผ ์ ์ ํ์ จ๋ค๋๊ฑธ ์๊ฒ๋์์ด์! next์์ ์ ๊ณตํ๋ ๊ธฐ๋ฅ ๊ด๋ จ ๋ด์ฉ(ํนํ ํธ๋ฆฌ ์์ดํน!)๋ ํฅ๋ฏธ๋กญ๊ฒ ๋ค์์ต๋๋ค!
yuiseo
No branches or pull requests
๐ Next.js vs React
๐ ์ฃผ์ :
React์ Next.js์ ์ฐจ์ด๋ฅผ ๋น๊ตํ๊ณ , Next.js๊ฐ ์ ๊ณตํ๋ ์ฃผ์ ๊ธฐ๋ฅ ๋ฐ ๊ฐ๋ ๋ค์ ์ ๋ฆฌํฉ๋๋ค.
๐ฏ ์คํฐ๋ ๋ชฉํ
๐ ํต์ฌ ๋ด์ฉ:
1. React์ Next.js์ ์ฃผ์ ์ฐจ์ด์
react-router
ํ์getServerSideProps
,getStaticProps
์ ๊ณตnext/image
๊ธฐ๋ณธ ์ ๊ณต2. Next.js์ ์ฃผ์ ๊ฐ๋ ๋ฐ ํน์ง
(1) ๋ ๋๋ง ๋ฐฉ์
Next.js๋ ๋ค์ํ ๋ ๋๋ง ๋ฐฉ์์ ์ง์ํ์ฌ ํ์ด์ง ์๊ตฌ์ฌํญ์ ๋ฐ๋ผ ํจ์จ์ ์ผ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
(2) ํ์ผ ๊ธฐ๋ฐ ๋ผ์ฐํ
pages/index.js
โ/
pages/about.js
โ/about
(3) ๋ฐ์ดํฐ ํจ์นญ
Next.js๋ ์๋ฒ์ ํด๋ผ์ด์ธํธ ๋ชจ๋์์ ๋ฐ์ดํฐ๋ฅผ ํจ์นญํ ์ ์๋ ๋ด์ฅ ๋ฉ์๋๋ฅผ ์ ๊ณตํฉ๋๋ค.
getStaticProps
: ๋น๋ ์ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ ์ ์ ์ฝํ ์ธ ์์ฑ.getServerSideProps
: ์์ฒญ ์ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ ์๋ฒ์์ ๋ ๋๋ง.getStaticPaths
: ๋์ ์ ์ ํ์ด์ง๋ฅผ ์์ฑ.(4) API Routes
/api/hello
๋ก ์์ฒญ ์ API ์๋ต์ ์ ๊ณต.(5) ์๋ ์ฝ๋ ์คํ๋ฆฌํ
dynamic import
๋ฅผ ํตํด ํน์ ์ปดํฌ๋ํธ๋ฅผ ํ์ํ ๋๋ง ๋ก๋:(6) ํธ๋ฆฌ ์์ดํน
(7) ์ด๋ฏธ์ง ์ต์ ํ
next/image
์ปดํฌ๋ํธ๋ฅผ ์ ๊ณตํ์ฌ ์ด๋ฏธ์ง ์ต์ ํ๋ฅผ ์๋์ผ๋ก ์ฒ๋ฆฌํฉ๋๋ค.3. Next.js์ ์ฅ์
(1) SEO๊ฐ ์ค์ํ ํ๋ก์ ํธ
(2) ์ด๊ธฐ ๋ก๋ฉ ์๋ ๊ฐ์
(3) ๊ฐ๋ฐ ์์ฐ์ฑ ํฅ์
(4) ์ ์ง๋ณด์์ ํ์ฅ์ฑ
pages
,api
,public
)๋ก ์ ์ง๋ณด์๊ฐ ์ฉ์ดํ๋ฉฐ, ์๋ก์ด ๊ธฐ๋ฅ ์ถ๊ฐ ์ ์ผ๊ด์ฑ์ด ์ ์ง๋ฉ๋๋ค.4. Next.js ํ๋ก์ ํธ ๊ตฌ์กฐ
5. Next.js์ Opinionated ๊ตฌ์กฐ๊ฐ ์ฃผ๋ ์ด์
๐ก ์ฐธ๊ณ ์๋ฃ:
https://tech.nexr.kr/dbe3aa3b-b984-4912-9e37-8f5cc18c9e88
The text was updated successfully, but these errors were encountered: