shadcn-nextjs-page-generator 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +394 -0
- package/dist/index.cjs +1900 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1866 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jatmiko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# shadcn-page-gen
|
|
2
|
+
|
|
3
|
+
> CLI tool to generate production-ready Next.js pages with shadcn/ui, Tailwind CSS v4, and Framer Motion animations.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/shadcn-page-gen)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
✨ **Interactive CLI** - User-friendly prompts guide you through the generation process
|
|
11
|
+
🏗️ **Flexible Architecture** - Choose between DDD (Domain-Driven Design) or Simplified structure
|
|
12
|
+
🎨 **shadcn/ui Components** - Beautiful, accessible components built with Radix UI
|
|
13
|
+
💨 **Tailwind CSS v4** - Latest Tailwind with modern CSS-first syntax
|
|
14
|
+
🎭 **Framer Motion** - Smooth animations with configurable intensity
|
|
15
|
+
📊 **Complete CRUD** - Tables with search, filter, sort, pagination out of the box
|
|
16
|
+
🔄 **Multiple Data Fetching** - Support for Mock data, TanStack Query, or standard fetch
|
|
17
|
+
⚡ **TypeScript First** - Full type safety and IntelliSense support
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Run with npx (no installation required)
|
|
23
|
+
npx shadcn-page-gen
|
|
24
|
+
|
|
25
|
+
# Or install globally
|
|
26
|
+
npm install -g shadcn-page-gen
|
|
27
|
+
shadcn-page-gen
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Prerequisites
|
|
31
|
+
|
|
32
|
+
Your Next.js project should have:
|
|
33
|
+
|
|
34
|
+
- Next.js 14+ with App Router
|
|
35
|
+
- shadcn/ui components installed ([installation guide](https://ui.shadcn.com/docs/installation/next))
|
|
36
|
+
- Tailwind CSS v4+ configured
|
|
37
|
+
- TypeScript
|
|
38
|
+
|
|
39
|
+
## What Gets Generated
|
|
40
|
+
|
|
41
|
+
### DDD Architecture
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
modules/your-module/
|
|
45
|
+
├── domain/
|
|
46
|
+
│ ├── entities/your-module.entity.ts
|
|
47
|
+
│ └── repositories/your-module.repository.interface.ts
|
|
48
|
+
├── application/
|
|
49
|
+
│ └── use-cases/get-your-modules.use-case.ts
|
|
50
|
+
├── infrastructure/
|
|
51
|
+
│ └── repositories/your-module.repository.ts
|
|
52
|
+
└── presentation/
|
|
53
|
+
└── components/your-module-list.tsx
|
|
54
|
+
|
|
55
|
+
app/(dashboard)/your-route/
|
|
56
|
+
├── page.tsx
|
|
57
|
+
└── template.tsx # if animations enabled
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Simplified Architecture
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
components/your-module/
|
|
64
|
+
└── your-module-list.tsx
|
|
65
|
+
|
|
66
|
+
app/(dashboard)/your-route/
|
|
67
|
+
├── page.tsx
|
|
68
|
+
└── template.tsx # if animations enabled
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
|
|
73
|
+
### 1. Run the CLI
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx shadcn-page-gen
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 2. Answer Interactive Prompts
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
? What is the name of the page? User Management
|
|
83
|
+
? What is the route path? admin/users
|
|
84
|
+
? Choose architecture pattern: DDD (Domain-Driven Design)
|
|
85
|
+
? What is the Entity name? User
|
|
86
|
+
? Use default columns? Yes
|
|
87
|
+
? Add filters? Yes
|
|
88
|
+
? Include Stats Cards at the top? Yes
|
|
89
|
+
? Include Row Selection (Checkboxes)? No
|
|
90
|
+
? Data Fetching Strategy? TanStack Query
|
|
91
|
+
? Enable Column Sorting? Yes
|
|
92
|
+
? Add page transition animations? Yes
|
|
93
|
+
? Animate table rows on load? Yes
|
|
94
|
+
? Animation intensity: Moderate (balanced)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 3. Install Dependencies (if needed)
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# If you selected TanStack Query
|
|
101
|
+
npm install @tanstack/react-query
|
|
102
|
+
|
|
103
|
+
# If you enabled animations
|
|
104
|
+
npm install framer-motion
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 4. Navigate to Your Page
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npm run dev
|
|
111
|
+
# Visit http://localhost:3000/admin/users
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Generated Features
|
|
115
|
+
|
|
116
|
+
### 📋 Table Features
|
|
117
|
+
|
|
118
|
+
- **Search** - Full-text search across columns
|
|
119
|
+
- **Filters** - Select, Date, and Input filters
|
|
120
|
+
- **Sorting** - Configurable column sorting (ASC/DESC)
|
|
121
|
+
- **Pagination** - Page size selection (10, 20, 30, 50, 100)
|
|
122
|
+
- **Row Actions** - View, Edit, Delete buttons
|
|
123
|
+
- **Row Selection** - Optional checkboxes for bulk actions
|
|
124
|
+
|
|
125
|
+
### 📊 Optional Features
|
|
126
|
+
|
|
127
|
+
- **Stats Cards** - 4 metric cards at the top
|
|
128
|
+
- **Animations** - Framer Motion with 3 intensity levels (subtle, moderate, bold)
|
|
129
|
+
- Page transitions
|
|
130
|
+
- List stagger animations
|
|
131
|
+
- Card animations
|
|
132
|
+
|
|
133
|
+
### 🔄 Data Fetching Strategies
|
|
134
|
+
|
|
135
|
+
1. **Mock Data (Default)**
|
|
136
|
+
- Repository pattern with in-memory data
|
|
137
|
+
- 10 sample items
|
|
138
|
+
- 500ms simulated API delay
|
|
139
|
+
|
|
140
|
+
2. **TanStack Query**
|
|
141
|
+
- Automatic caching and revalidation
|
|
142
|
+
- Optimistic updates
|
|
143
|
+
- Query key based on search params
|
|
144
|
+
|
|
145
|
+
3. **Standard Fetch**
|
|
146
|
+
- Basic `useEffect` + `useState`
|
|
147
|
+
- Simple for beginners
|
|
148
|
+
- Easy to customize
|
|
149
|
+
|
|
150
|
+
## Architecture Options
|
|
151
|
+
|
|
152
|
+
### DDD (Domain-Driven Design)
|
|
153
|
+
|
|
154
|
+
**Best for:**
|
|
155
|
+
- Large applications
|
|
156
|
+
- Team projects
|
|
157
|
+
- Complex business logic
|
|
158
|
+
- Maintainability and testability
|
|
159
|
+
|
|
160
|
+
**Structure:**
|
|
161
|
+
- Domain layer (Entities, Repositories)
|
|
162
|
+
- Application layer (Use Cases)
|
|
163
|
+
- Infrastructure layer (Implementations)
|
|
164
|
+
- Presentation layer (Components)
|
|
165
|
+
|
|
166
|
+
### Simplified
|
|
167
|
+
|
|
168
|
+
**Best for:**
|
|
169
|
+
- Small projects
|
|
170
|
+
- Prototypes
|
|
171
|
+
- Simple CRUD operations
|
|
172
|
+
- Quick iterations
|
|
173
|
+
|
|
174
|
+
**Structure:**
|
|
175
|
+
- Components folder
|
|
176
|
+
- Direct data fetching
|
|
177
|
+
- No layered architecture
|
|
178
|
+
|
|
179
|
+
## Animation Variants
|
|
180
|
+
|
|
181
|
+
### Subtle (Professional)
|
|
182
|
+
```typescript
|
|
183
|
+
initial: { opacity: 0, y: 10 }
|
|
184
|
+
animate: { opacity: 1, y: 0 }
|
|
185
|
+
transition: { duration: 0.2 }
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Moderate (Balanced)
|
|
189
|
+
```typescript
|
|
190
|
+
initial: { opacity: 0, y: 20 }
|
|
191
|
+
animate: { opacity: 1, y: 0 }
|
|
192
|
+
transition: { duration: 0.3, ease: "easeInOut" }
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Bold (Eye-catching)
|
|
196
|
+
```typescript
|
|
197
|
+
initial: { opacity: 0, scale: 0.95, y: 30 }
|
|
198
|
+
animate: { opacity: 1, scale: 1, y: 0 }
|
|
199
|
+
transition: { duration: 0.4 }
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Examples
|
|
203
|
+
|
|
204
|
+
### Generate User Management Page
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
npx shadcn-page-gen
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Configuration:**
|
|
211
|
+
- Page Name: "User Management"
|
|
212
|
+
- Route: "admin/users"
|
|
213
|
+
- Architecture: DDD
|
|
214
|
+
- Columns: Name, Email, Role, Created At
|
|
215
|
+
- Filters: Role (Select), Status (Select)
|
|
216
|
+
- Features: Stats Cards ✓, Row Selection ✗
|
|
217
|
+
- Data Fetching: TanStack Query
|
|
218
|
+
- Animations: Moderate intensity
|
|
219
|
+
|
|
220
|
+
### Generate Simple Product List
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
npx shadcn-page-gen
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**Configuration:**
|
|
227
|
+
- Page Name: "Products"
|
|
228
|
+
- Route: "products"
|
|
229
|
+
- Architecture: Simplified
|
|
230
|
+
- Columns: Name, Price, Stock, Category
|
|
231
|
+
- Filters: Category (Select)
|
|
232
|
+
- Features: Stats Cards ✗, Row Selection ✓
|
|
233
|
+
- Data Fetching: Mock
|
|
234
|
+
- Animations: Subtle intensity
|
|
235
|
+
|
|
236
|
+
## Customization
|
|
237
|
+
|
|
238
|
+
### Replace Mock Data with Real API
|
|
239
|
+
|
|
240
|
+
#### DDD Architecture
|
|
241
|
+
|
|
242
|
+
Edit `infrastructure/repositories/your-module.repository.ts`:
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
async findAll(params?: any): Promise<Entity[]> {
|
|
246
|
+
// Replace mock implementation
|
|
247
|
+
const response = await fetch('/api/your-endpoint');
|
|
248
|
+
return await response.json();
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### Simplified Architecture
|
|
253
|
+
|
|
254
|
+
Edit `components/your-module/your-module-list.tsx`:
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
// Find the fetchData function or useQuery
|
|
258
|
+
const response = await fetch('/api/your-endpoint');
|
|
259
|
+
const data = await response.json();
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Add TanStack Query Provider
|
|
263
|
+
|
|
264
|
+
Wrap your app in `app/layout.tsx`:
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
'use client';
|
|
268
|
+
|
|
269
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
270
|
+
import { useState } from 'react';
|
|
271
|
+
|
|
272
|
+
export default function RootLayout({ children }) {
|
|
273
|
+
const [queryClient] = useState(() => new QueryClient());
|
|
274
|
+
|
|
275
|
+
return (
|
|
276
|
+
<QueryClientProvider client={queryClient}>
|
|
277
|
+
{children}
|
|
278
|
+
</QueryClientProvider>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Customize Animations
|
|
284
|
+
|
|
285
|
+
Edit animation variants in generated component:
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
const containerVariants = {
|
|
289
|
+
hidden: { opacity: 0 },
|
|
290
|
+
visible: {
|
|
291
|
+
opacity: 1,
|
|
292
|
+
transition: {
|
|
293
|
+
staggerChildren: 0.1, // Adjust stagger delay
|
|
294
|
+
delayChildren: 0.2, // Add delay before children animate
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## shadcn/ui Components Used
|
|
301
|
+
|
|
302
|
+
The generated code uses these shadcn/ui components:
|
|
303
|
+
|
|
304
|
+
- `button`
|
|
305
|
+
- `table`
|
|
306
|
+
- `card`
|
|
307
|
+
- `input`
|
|
308
|
+
- `select`
|
|
309
|
+
- `badge`
|
|
310
|
+
- `pagination`
|
|
311
|
+
- `dropdown-menu`
|
|
312
|
+
- `popover`
|
|
313
|
+
- `calendar` (if date filters)
|
|
314
|
+
- `checkbox` (if row selection)
|
|
315
|
+
|
|
316
|
+
Make sure to install them:
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
npx shadcn-ui@latest add button table card input select badge pagination dropdown-menu popover calendar checkbox
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## FAQ
|
|
323
|
+
|
|
324
|
+
### Can I use this with Pages Router?
|
|
325
|
+
|
|
326
|
+
Currently, this tool generates code for Next.js App Router only. Pages Router support may be added in the future.
|
|
327
|
+
|
|
328
|
+
### Does this work with JavaScript projects?
|
|
329
|
+
|
|
330
|
+
The generated code is TypeScript. You can remove type annotations manually, but TypeScript is recommended for better developer experience.
|
|
331
|
+
|
|
332
|
+
### Can I customize the templates?
|
|
333
|
+
|
|
334
|
+
Currently, templates are built into the CLI. Custom template support is planned for a future release.
|
|
335
|
+
|
|
336
|
+
### What if I don't use shadcn/ui?
|
|
337
|
+
|
|
338
|
+
This tool is specifically designed for shadcn/ui. Using other component libraries would require significant code changes.
|
|
339
|
+
|
|
340
|
+
### How do I update the generated code?
|
|
341
|
+
|
|
342
|
+
The generated code is meant to be a starting point. Edit it directly in your project - it won't be overwritten unless you regenerate to the same location.
|
|
343
|
+
|
|
344
|
+
## Troubleshooting
|
|
345
|
+
|
|
346
|
+
### "Module not found" errors
|
|
347
|
+
|
|
348
|
+
Make sure you've installed all required shadcn/ui components and dependencies.
|
|
349
|
+
|
|
350
|
+
### TanStack Query not working
|
|
351
|
+
|
|
352
|
+
Ensure your app is wrapped in `<QueryClientProvider>`. See [Customization](#add-tanstack-query-provider) above.
|
|
353
|
+
|
|
354
|
+
### Tailwind styles not applying
|
|
355
|
+
|
|
356
|
+
Check that your `tailwind.config.ts` includes the generated file paths:
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
content: [
|
|
360
|
+
'./app/**/*.{ts,tsx}',
|
|
361
|
+
'./components/**/*.{ts,tsx}',
|
|
362
|
+
'./modules/**/*.{ts,tsx}', // For DDD architecture
|
|
363
|
+
]
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### Framer Motion animations not showing
|
|
367
|
+
|
|
368
|
+
Install framer-motion:
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
npm install framer-motion
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## Contributing
|
|
375
|
+
|
|
376
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
|
377
|
+
|
|
378
|
+
## License
|
|
379
|
+
|
|
380
|
+
MIT © SALT Solutions
|
|
381
|
+
|
|
382
|
+
## Credits
|
|
383
|
+
|
|
384
|
+
Built with:
|
|
385
|
+
- [Next.js](https://nextjs.org/)
|
|
386
|
+
- [shadcn/ui](https://ui.shadcn.com/)
|
|
387
|
+
- [Tailwind CSS](https://tailwindcss.com/)
|
|
388
|
+
- [Framer Motion](https://www.framer.com/motion/)
|
|
389
|
+
- [TanStack Query](https://tanstack.com/query)
|
|
390
|
+
- [Radix UI](https://www.radix-ui.com/)
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
Made with ❤️ by SALT Solutions
|