Next.js

[Next.js] Next ํ”„๋กœ์ ํŠธ ์ˆ˜๋™ setup

jjingle 2024. 3. 14. 17:17

1.  ํ”„๋กœ์ ํŠธ ํด๋” ๋งŒ๋“ค๊ธฐ

$ mkdir prj_folder

 

2. ํ”„๋กœ์ ํŠธ ํด๋”๋กœ ์ด๋™

$ cd prj_folder

 

3. ํ•ด๋‹น ํด๋”๋ฅผ VSCode์—์„œ ์—ด์–ด๋ณด๊ธฐ

$ code .

 

4. package.json ํด๋” ์ƒ์„ฑ

$ npm init -y

 

5. ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์„ค์น˜

  - react : UI์™€ ๋‹ค๋ฅธ ๋ชจ๋“  ๊ฒƒ์„ ๊ตฌ์„ฑ

  - react-dom : ์œ„์˜ ๊ฒƒ์„ ๋ธŒ๋ผ์šฐ์ €์˜ Document Object Model(DOM)์— ๋ Œ๋”ํ•˜๋Š” ์—ญํ• 

$ npm install react@latest next@latest react-dom@latest

 

6. jackage.json ์Šคํฌ๋ฆฝํŠธ ์ˆ˜์ •

"scripts" : {
	"dev" : "next dev"
},

 

7. ํ”„๋กœ์ ํŠธ ์‹คํ–‰ ํ™•์ธ

$ npm run dev

  - local server ์‹คํ–‰ : http://localhost:3000

  - Next.js๊ฐ€ ์ž๋™์œผ๋กœ

      - typeScript dependencies ์„ค์น˜

      - app/page.tsx ๋ฅผ ์ฐธ์กฐํ•˜์—ฌ ํ™”๋ฉด ๋„์–ด์คŒ

      - app/layout.tsx  ํŒŒ์ผ ์ƒ์„ฑ

 

8. README.md ํŒŒ์ผ ์ถ”๊ฐ€

$ touch README.md

'Next.js' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Next.js] fetch data, React vs Next.js  (0) 2024.03.19
[Next.js] Server component vs Client component  (0) 2024.03.19
[Next.js] Library vs Framework  (1) 2024.03.15
[Next.js] CSR(client side render) vs SSR(server side render)  (0) 2024.03.15