UNPKG

create-react-shadcn-app

Version:

CLI tool to create React applications with shadcn/ui components

198 lines (145 loc) β€’ 5.81 kB
# πŸš€ create-react-shadcn-app React + shadcn/ui μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ„ λΉ λ₯΄κ²Œ μƒμ„±ν•˜λŠ” CLI 도ꡬ ## πŸ“¦ μ‚¬μš© κ°€λŠ₯ν•œ ν…œν”Œλ¦Ώ ### 1. πŸ”₯ React + Vite **ν…œν”Œλ¦Ώλͺ…**: `react-vite` λΉ λ₯Έ κ°œλ°œμ„ μœ„ν•œ Vite와 νƒ€μž… μ•ˆμ „ν•œ λΌμš°νŒ…μ„ μœ„ν•œ TanStack Routerκ°€ ν¬ν•¨λœ ν˜„λŒ€μ μΈ React λ³΄μΌλŸ¬ν”Œλ ˆμ΄νŠΈμž…λ‹ˆλ‹€. **기술 μŠ€νƒ**: - React 19 + TypeScript - Vite (λΉŒλ“œ 도ꡬ) - TanStack Router (νƒ€μž… μ•ˆμ „ν•œ λΌμš°νŒ…) - Tailwind CSS v4 - shadcn/ui μ»΄ν¬λ„ŒνŠΈ - Jotai (μƒνƒœ 관리) - TanStack Query (μ„œλ²„ μƒνƒœ) ### 2. ⚑ Next.js App Router **ν…œν”Œλ¦Ώλͺ…**: `nextjs-app-router` μ„œλ²„ μ»΄ν¬λ„ŒνŠΈμ™€ μŠ€νŠΈλ¦¬λ°μ„ μ§€μ›ν•˜λŠ” ν˜„λŒ€μ μΈ App Routerλ₯Ό μ‚¬μš©ν•œ Next.js λ³΄μΌλŸ¬ν”Œλ ˆμ΄νŠΈμž…λ‹ˆλ‹€. **기술 μŠ€νƒ**: - Next.js 15 + App Router - TypeScript - Tailwind CSS v4 - shadcn/ui μ»΄ν¬λ„ŒνŠΈ - Jotai (μƒνƒœ 관리) - TanStack Query (μ„œλ²„ μƒνƒœ) ### 3. πŸ“„ Next.js Pages Router **ν…œν”Œλ¦Ώλͺ…**: `nextjs-pages-router` 전톡적인 Pages Routerλ₯Ό μ‚¬μš©ν•œ Next.js λ³΄μΌλŸ¬ν”Œλ ˆμ΄νŠΈμž…λ‹ˆλ‹€. κΈ°μ‘΄ ν”„λ‘œμ νŠΈλ‚˜ νŠΉμ • μš”κ΅¬μ‚¬ν•­μ΄ μžˆλŠ” κ²½μš°μ— μ ν•©ν•©λ‹ˆλ‹€. **기술 μŠ€νƒ**: - Next.js 15 + Pages Router - TypeScript - Tailwind CSS v4 - shadcn/ui μ»΄ν¬λ„ŒνŠΈ - Jotai (μƒνƒœ 관리) - TanStack Query (μ„œλ²„ μƒνƒœ) ## πŸš€ λΉ λ₯Έ μ‹œμž‘ ### npx μ‚¬μš© (ꢌμž₯) ```bash # React + Vite ν”„λ‘œμ νŠΈ 생성 npx create-react-shadcn-app react-vite my-app # Next.js App Router ν”„λ‘œμ νŠΈ 생성 npx create-react-shadcn-app nextjs-app-router my-dashboard # Next.js Pages Router ν”„λ‘œμ νŠΈ 생성 npx create-react-shadcn-app nextjs-pages-router my-blog ``` ### μ „μ—­ μ„€μΉ˜ ν›„ μ‚¬μš© ```bash # μ „μ—­ μ„€μΉ˜ npm install -g create-react-shadcn-app # ν”„λ‘œμ νŠΈ 생성 create-react-shadcn-app react-vite my-app create-react-shadcn-app nextjs-app-router my-dashboard create-react-shadcn-app nextjs-pages-router my-blog ``` ### degit μ‚¬μš© (λŒ€μ•ˆ) ```bash # ν…œν”Œλ¦Ώμ„ 직접 볡사 npx degit im-ian/create-react-shadcn-app/packages/react-vite my-app npx degit im-ian/create-react-shadcn-app/packages/nextjs-app-router my-dashboard npx degit im-ian/create-react-shadcn-app/packages/nextjs-pages-router my-blog # μ˜μ‘΄μ„± μ„€μΉ˜ 및 개발 μ„œλ²„ μ‹œμž‘ cd my-app npm install npm run dev ``` ## πŸ› οΈ 곡톡 κΈ°λŠ₯ λͺ¨λ“  ν…œν”Œλ¦Ώμ— ν¬ν•¨λœ κΈ°λŠ₯: - βœ… **TypeScript** νƒ€μž… μ•ˆμ „μ„± - βœ… **Tailwind CSS v4** ν˜„λŒ€μ μΈ μŠ€νƒ€μΌλ§ - βœ… **shadcn/ui** Tailwind 기반의 UI μ»΄ν¬λ„ŒνŠΈ - βœ… **Jotai** μ›μžμ  μƒνƒœ 관리 - βœ… **TanStack Query** μ„œλ²„ μƒνƒœ 관리 - βœ… **ESLint** μ½”λ“œ ν’ˆμ§ˆ 관리 - βœ… **도메인 기반 폴더 ꡬ쑰** - βœ… **ν˜„λŒ€μ μΈ 개발 도ꡬ** ## πŸ“ ν”„λ‘œμ νŠΈ ꡬ쑰 각 ν…œν”Œλ¦Ώμ€ μΌκ΄€λœ 도메인 기반 ꡬ쑰λ₯Ό λ”°λ¦…λ‹ˆλ‹€: ``` src/ β”œβ”€β”€ components/ # 곡유/곡톡 μ»΄ν¬λ„ŒνŠΈ β”‚ └── ui/ # shadcn/ui μ»΄ν¬λ„ŒνŠΈ β”œβ”€β”€ domains/ # 도메인 기반 ꡬ성 β”‚ β”œβ”€β”€ user/ β”‚ β”‚ β”œβ”€β”€ components/ β”‚ β”‚ β”œβ”€β”€ hooks/ β”‚ β”‚ └── index.ts β”‚ β”œβ”€β”€ product/ β”‚ └── order/ β”œβ”€β”€ hooks/ # 곡유 ν›… β”œβ”€β”€ lib/ # μœ ν‹Έλ¦¬ν‹° 및 μ„€μ • └── ... # ν”„λ ˆμž„μ›Œν¬λ³„ 파일 ``` ## 🎯 각 ν…œν”Œλ¦Ώ μ‚¬μš© μ‹œκΈ° ### React + Vite - **μ ν•©ν•œ μš©λ„**: SPA, ν΄λΌμ΄μ–ΈνŠΈ μ‚¬μ΄λ“œ μ• ν”Œλ¦¬μΌ€μ΄μ…˜, λΉ λ₯Έ ν”„λ‘œν† νƒ€μ΄ν•‘ - **μž₯점**: λΉ λ₯Έ 개발, κ°„λ‹¨ν•œ 배포, μ™„μ „ν•œ ν΄λΌμ΄μ–ΈνŠΈ μ‚¬μ΄λ“œ μ œμ–΄ - **μ‚¬μš© 사둀**: λŒ€μ‹œλ³΄λ“œ, κ΄€λ¦¬μž νŒ¨λ„, μΈν„°λž™ν‹°λΈŒ μ›Ή μ•± ### Next.js App Router - **μ ν•©ν•œ μš©λ„**: ν’€μŠ€νƒ μ• ν”Œλ¦¬μΌ€μ΄μ…˜, SEOκ°€ μ€‘μš”ν•œ μ‚¬μ΄νŠΈ, ν˜„λŒ€μ μΈ React νŒ¨ν„΄ - **μž₯점**: μ„œλ²„ μ»΄ν¬λ„ŒνŠΈ, 슀트리밍, λ‚΄μž₯ μ΅œμ ν™”, SEO μΉœν™”μ  - **μ‚¬μš© 사둀**: λ§ˆμΌ€νŒ… μ‚¬μ΄νŠΈ, 이컀머슀, λΈ”λ‘œκ·Έ, λ³΅μž‘ν•œ μ›Ή μ• ν”Œλ¦¬μΌ€μ΄μ…˜ ### Next.js Pages Router - **μ ν•©ν•œ μš©λ„**: κΈ°μ‘΄ Next.js ν”„λ‘œμ νŠΈ, 점진적 λ§ˆμ΄κ·Έλ ˆμ΄μ…˜, νŠΉμ • μš”κ΅¬μ‚¬ν•­ - **μž₯점**: μ„±μˆ™ν•œ μƒνƒœκ³„, 잘 λ¬Έμ„œν™”λ¨, μ•ˆμ •μ μΈ API - **μ‚¬μš© 사둀**: λ ˆκ±°μ‹œ ν”„λ‘œμ νŠΈ, νŠΉμ • λΌμš°νŒ… μš”κ΅¬μ‚¬ν•­, 점진적 λ„μž… ## πŸ”§ μ»€μŠ€ν„°λ§ˆμ΄μ§• ### μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€ λͺ¨λ“  ν…œν”Œλ¦Ώμ€ shadcn/uiλ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€. μƒˆ μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€: ```bash npx shadcn@latest add [μ»΄ν¬λ„ŒνŠΈλͺ…] ``` ### μƒνƒœ 관리 - **ν΄λΌμ΄μ–ΈνŠΈ μƒνƒœ**: Jotai atoms μ‚¬μš© - **μ„œλ²„ μƒνƒœ**: TanStack Query μ‚¬μš© - **폼 μƒνƒœ**: react-hook-form (ν•„μš”μ‹œ μΆ”κ°€) ### μŠ€νƒ€μΌλ§ - `globals.css`μ—μ„œ Tailwind CSS μ»€μŠ€ν„°λ§ˆμ΄μ§• - shadcn/ui ν…Œλ§ˆ λ³€μˆ˜ μˆ˜μ • - `components/ui/`에 μ»€μŠ€ν…€ μ»΄ν¬λ„ŒνŠΈ μΆ”κ°€ ## πŸ“ 슀크립트 각 ν…œν”Œλ¦Ώμ— ν¬ν•¨λœ 곡톡 슀크립트: ```bash npm run dev # 개발 μ„œλ²„ μ‹œμž‘ npm run build # ν”„λ‘œλ•μ…˜ λΉŒλ“œ npm run lint # ESLint μ‹€ν–‰ npm run preview # ν”„λ‘œλ•μ…˜ λΉŒλ“œ 미리보기 (Vite만) npm run start # ν”„λ‘œλ•μ…˜ μ„œλ²„ μ‹œμž‘ (Next.js만) ``` ## πŸš€ 배포 ### React + Vite - **ꢌμž₯**: Vercel, Netlify, GitHub Pages - **λΉŒλ“œ**: `npm run build` β†’ `dist/` 폴더 ### Next.js (App Router & Pages Router) - **ꢌμž₯**: Vercel (제둜 μ„€μ •) - **λŒ€μ•ˆ**: Netlify, AWS, Docker - **λΉŒλ“œ**: `npm run build` β†’ `.next/` 폴더 ## 🀝 κΈ°μ—¬ν•˜κΈ° 1. μ €μž₯μ†Œ 포크 2. κΈ°λŠ₯ 브랜치 생성 (`git checkout -b feature/amazing-feature`) 3. 변경사항 컀밋 (`git commit -m 'Add some amazing feature'`) 4. λΈŒλžœμΉ˜μ— ν‘Έμ‹œ (`git push origin feature/amazing-feature`) 5. Pull Request μ—΄κΈ° ## πŸ“„ λΌμ΄μ„ μŠ€ 이 ν”„λ‘œμ νŠΈλŠ” MIT λΌμ΄μ„ μŠ€ ν•˜μ— μžˆμŠ΅λ‹ˆλ‹€. --- **λΉ λ₯΄κ²Œ μ‹œμž‘ν•˜κ³  λ©‹μ§„ 앱을 λ§Œλ“€μ–΄λ³΄μ„Έμš”! πŸŽ‰**