payload-next-starter 1.0.6 → 1.0.7

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/README.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Payload Next.js Starter
2
2
 
3
- Quickly add PayloadCMS to any existing Next.js project. This package scaffolds PayloadCMS with PostgreSQL support into your Next.js application.
3
+ A block-based page builder powered by PayloadCMS for Next.js. Install this package into any Next.js project to add a full CMS with dynamic page content that can be shared across multiple applications.
4
+
5
+ ## Features
6
+
7
+ - **Block-Based Page Builder** — Hero, Content, Contact Form, Features, Pricing, Testimonials, CTA, Team, FAQ, Image Gallery
8
+ - **Multi-App Support** — Share one PostgreSQL database across multiple Next.js apps
9
+ - **Admin Panel** — Visual editor for managing pages and content
10
+ - **Dynamic Routes** — Automatic page rendering at `/[slug]`
11
+ - **SEO Fields** — Meta titles, descriptions, images per page
12
+ - **Draft Mode** — Preview changes before publishing
13
+ - **TypeScript** — Full type safety with generated types
4
14
 
5
15
  ## Installation
6
16
 
@@ -19,31 +29,36 @@ payload-next-starter
19
29
 
20
30
  ## What it does
21
31
 
22
- This CLI tool will:
32
+ The setup script will:
23
33
  1. Copy Payload admin routes to `src/app/(payload)/`
24
34
  2. Copy API routes to `src/app/api/[...payload]/`
25
- 3. Copy collections (Users, Media) to `src/collections/`
26
- 4. Install required dependencies
27
- 5. Update `next.config.ts` with Payload plugin
28
- 6. Create `.env.example` with required variables
29
-
30
- ## After installation
35
+ 3. Copy collections (Users, Media, Pages) to `src/collections/`
36
+ 4. Copy block components to `src/components/blocks/`
37
+ 5. Copy BlockRenderer and RichTextContent components
38
+ 6. Copy dynamic `[slug]` page renderer to `src/app/(frontend)/[slug]/`
39
+ 7. Copy seed script to `src/scripts/seedPages.ts`
40
+ 8. Install required dependencies
41
+ 9. Update `next.config.ts` with Payload plugin
42
+ 10. Add scripts to `package.json`
43
+ 11. Create `.env.example` with required variables
44
+
45
+ ## After Installation
31
46
 
32
47
  1. Copy `.env.example` to `.env` and fill in your values:
33
48
  ```bash
34
- DATABASE_URI=postgresql://user:password@host:5432/database
49
+ DATABASE_URL=postgresql://user:password@host:5432/database?sslmode=require
35
50
  PAYLOAD_SECRET=your-secret-key-min-16-chars
36
51
  NEXT_PUBLIC_SERVER_URL=http://localhost:3000
37
52
  ```
38
53
 
39
54
  2. Generate Payload import maps:
40
55
  ```bash
41
- npx payload generate:importmap
56
+ npm run generate:importmap
42
57
  ```
43
58
 
44
59
  3. Generate TypeScript types:
45
60
  ```bash
46
- npx payload generate:types
61
+ npm run generate:types
47
62
  ```
48
63
 
49
64
  4. Start your dev server:
@@ -53,16 +68,61 @@ This CLI tool will:
53
68
 
54
69
  5. Visit `http://localhost:3000/admin` to create your first admin user
55
70
 
71
+ 6. Seed sample pages (optional):
72
+ ```bash
73
+ npm run seed:pages
74
+ ```
75
+
76
+ ## Using in Another Next.js App
77
+
78
+ This package is designed to be installed in multiple Next.js apps that share the same database. See [CONSUMER_GUIDE.md](./CONSUMER_GUIDE.md) for detailed instructions on:
79
+
80
+ - Installing the package in a consumer app
81
+ - Configuring the shared database connection
82
+ - Rendering dynamic pages with BlockRenderer
83
+ - Using individual block components
84
+ - Managing content across multiple apps
85
+
86
+ ## Collections Included
87
+
88
+ - **Users** — Authentication-enabled collection with admin access
89
+ - **Media** — Uploads collection with image handling
90
+ - **Pages** — Block-based page builder with SEO fields
91
+
92
+ ## Available Blocks
93
+
94
+ | Block | Description |
95
+ |-------|-------------|
96
+ | `HeroBlock` | Hero section with title, subtitle, CTA |
97
+ | `ContentBlock` | Rich text content with heading |
98
+ | `ContactFormBlock` | Contact form with info display |
99
+ | `FeaturesBlock` | Feature grid with icons |
100
+ | `PricingBlock` | Pricing plans table |
101
+ | `TestimonialsBlock` | Customer testimonials |
102
+ | `CTABlock` | Call-to-action banner |
103
+ | `TeamBlock` | Team member cards |
104
+ | `FAQBlock` | Accordion FAQ section |
105
+ | `ImageGalleryBlock` | Image grid gallery |
106
+
107
+ ## Sample Pages
108
+
109
+ After running `npm run seed:pages`, the following sample pages are created:
110
+
111
+ | Route | Content |
112
+ |-------|---------|
113
+ | `/home` | Hero → Features → Testimonials → CTA |
114
+ | `/about-us` | Hero → Story → Values → Team → CTA |
115
+ | `/contact-us` | Hero → Contact Form → FAQ |
116
+ | `/services` | Hero → Services → How We Work → CTA |
117
+ | `/pricing` | Hero → Pricing → FAQ → CTA |
118
+ | `/faq` | Hero → General FAQ → Technical FAQ → CTA |
119
+ | `/share` | Hero → Share Ways → Referral → Testimonials → CTA |
120
+
56
121
  ## Requirements
57
122
 
58
123
  - Next.js 13+ with App Router
59
124
  - Node.js 18.20+ or 20.9+
60
- - PostgreSQL database
61
-
62
- ## Collections included
63
-
64
- - **Users** - Authentication-enabled collection with admin access
65
- - **Media** - Uploads collection with image handling
125
+ - PostgreSQL database (Neon, Supabase, or any managed Postgres)
66
126
 
67
127
  ## Deploying
68
128
 
@@ -73,7 +133,7 @@ npm run build
73
133
  ```
74
134
 
75
135
  Ensure these environment variables are set in production:
76
- - `DATABASE_URI`
136
+ - `DATABASE_URL`
77
137
  - `PAYLOAD_SECRET`
78
138
  - `NEXT_PUBLIC_SERVER_URL`
79
139
 
@@ -84,7 +144,9 @@ Edit `src/payload.config.ts` to add:
84
144
  - Globals
85
145
  - Hooks
86
146
  - Access control
87
- - Custom components
147
+ - Custom block types
148
+
149
+ Edit block components in `src/components/blocks/` to customize styling and behavior.
88
150
 
89
151
  ## License
90
152
 
@@ -92,4 +154,7 @@ MIT
92
154
 
93
155
  ## Support
94
156
 
95
- [GitHub Issues](https://github.com/sentayhu19/test-payload/issues)
157
+ - [GitHub Issues](https://github.com/sentayhu19/test-payload/issues)
158
+ - [Consumer Guide](./CONSUMER_GUIDE.md) — For using in other Next.js apps
159
+ - [Payload Docs](https://payloadcms.com/docs)
160
+
package/bin/setup.js CHANGED
@@ -39,6 +39,8 @@ try {
39
39
  mkdirSync(join(targetDir, 'src/components'), { recursive: true })
40
40
  mkdirSync(join(targetDir, 'src/components/blocks'), { recursive: true })
41
41
  mkdirSync(join(targetDir, 'src/lib'), { recursive: true })
42
+ mkdirSync(join(targetDir, 'src/scripts'), { recursive: true })
43
+ mkdirSync(join(targetDir, 'src/app/next/preview'), { recursive: true })
42
44
  } catch (e) {
43
45
  // Directories might already exist
44
46
  }
@@ -94,6 +96,25 @@ if (existsSync(join(templatesDir, 'app/api/[...payload]'))) {
94
96
  console.log(' ✓ app/api/[...payload]/')
95
97
  }
96
98
 
99
+ // Copy preview route
100
+ if (existsSync(join(templatesDir, 'app/next/preview'))) {
101
+ mkdirSync(join(targetDir, 'src/app/next/preview'), { recursive: true })
102
+ cpSync(join(templatesDir, 'app/next/preview'), join(targetDir, 'src/app/next/preview'), {
103
+ recursive: true,
104
+ force: true,
105
+ })
106
+ console.log(' ✓ app/next/preview/ (draft mode)')
107
+ }
108
+
109
+ // Copy seed script
110
+ if (existsSync(join(templatesDir, 'scripts'))) {
111
+ cpSync(join(templatesDir, 'scripts'), join(targetDir, 'src/scripts'), {
112
+ recursive: true,
113
+ force: true,
114
+ })
115
+ console.log(' ✓ scripts/seedPages.ts')
116
+ }
117
+
97
118
  console.log('\n📦 Installing dependencies...')
98
119
 
99
120
  const deps = [
@@ -117,12 +138,38 @@ try {
117
138
  cwd: targetDir,
118
139
  stdio: 'inherit',
119
140
  })
141
+
142
+ // Install dev deps for seed script
143
+ execSync(`${pkgManager} add -D tsx cross-env`, {
144
+ cwd: targetDir,
145
+ stdio: 'inherit',
146
+ })
147
+
120
148
  console.log('✓ Dependencies installed\n')
121
149
  } catch (e) {
122
150
  console.error('❌ Failed to install dependencies:', e.message)
123
151
  process.exit(1)
124
152
  }
125
153
 
154
+ // Add seed script to package.json
155
+ console.log('📝 Adding scripts to package.json...')
156
+ try {
157
+ const targetPkg = JSON.parse(readFileSync(join(targetDir, 'package.json'), 'utf8'))
158
+ if (!targetPkg.scripts) targetPkg.scripts = {}
159
+ if (!targetPkg.scripts['seed:pages']) {
160
+ targetPkg.scripts['seed:pages'] =
161
+ 'cross-env NODE_OPTIONS=--no-deprecation tsx src/scripts/seedPages.ts'
162
+ targetPkg.scripts['generate:types'] =
163
+ 'cross-env NODE_OPTIONS=--no-deprecation payload generate:types'
164
+ targetPkg.scripts['generate:importmap'] =
165
+ 'cross-env NODE_OPTIONS=--no-deprecation payload generate:importmap'
166
+ writeFileSync(join(targetDir, 'package.json'), JSON.stringify(targetPkg, null, 2) + '\n')
167
+ console.log(' ✓ Added seed:pages, generate:types, generate:importmap scripts')
168
+ }
169
+ } catch (e) {
170
+ console.log(' ⚠ Could not update scripts in package.json')
171
+ }
172
+
126
173
  // Update next.config
127
174
  console.log('⚙️ Updating next.config...')
128
175
  const nextConfigPath = existsSync(join(targetDir, 'next.config.ts'))
@@ -180,4 +227,9 @@ console.log(' 1. Copy .env.example to .env and fill in your values')
180
227
  console.log(' 2. Run: npx payload generate:importmap')
181
228
  console.log(' 3. Run: npx payload generate:types')
182
229
  console.log(' 4. Start your dev server: npm run dev')
183
- console.log('\nAdmin panel will be at: http://localhost:3000/admin')
230
+ console.log(' 5. Seed sample pages: npm run seed:pages')
231
+ console.log(" (This only creates pages that don't already exist in the DB)")
232
+ console.log('\nAdmin panel: http://localhost:3000/admin')
233
+ console.log(
234
+ 'Pages: http://localhost:3000/home, /about-us, /contact-us, /services, /pricing, /faq, /share',
235
+ )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload-next-starter",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "PayloadCMS starter for Next.js - install into any Next.js app",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,6 +15,7 @@
15
15
  "templates/",
16
16
  "src/components/",
17
17
  "src/collections/",
18
+ "src/scripts/",
18
19
  "src/lib/",
19
20
  "README.md"
20
21
  ],
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import React, { useState } from 'react'
2
4
 
3
5
  type Question = {