create-content-sdk-app 2.0.2 → 2.1.0-canary.2

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.
Files changed (36) hide show
  1. package/LICENSE.MD +202 -202
  2. package/dist/templates/nextjs/.cursor/rules/general.mdc +81 -81
  3. package/dist/templates/nextjs/.cursor/rules/javascript.mdc +112 -112
  4. package/dist/templates/nextjs/.cursor/rules/project-setup.mdc +100 -100
  5. package/dist/templates/nextjs/.cursor/rules/sitecore.mdc +150 -150
  6. package/dist/templates/nextjs/.env.container.example +27 -27
  7. package/dist/templates/nextjs/.env.remote.example +51 -51
  8. package/dist/templates/nextjs/.gitattributes +11 -11
  9. package/dist/templates/nextjs/.prettierrc +8 -8
  10. package/dist/templates/nextjs/.vscode/extensions.json +8 -8
  11. package/dist/templates/nextjs/.vscode/launch.json +15 -15
  12. package/dist/templates/nextjs/.windsurfrules +186 -186
  13. package/dist/templates/nextjs/LICENSE.txt +202 -202
  14. package/dist/templates/nextjs/eslint.config.mjs +81 -81
  15. package/dist/templates/nextjs/gitignore +28 -28
  16. package/dist/templates/nextjs/package.json +68 -68
  17. package/dist/templates/nextjs/sitecore.config.ts.example +40 -40
  18. package/dist/templates/nextjs/src/proxy.ts +11 -3
  19. package/dist/templates/nextjs/tsconfig.json +40 -40
  20. package/dist/templates/nextjs-app-router/.cursor/rules/app-router-setup.mdc +116 -116
  21. package/dist/templates/nextjs-app-router/.cursor/rules/general.mdc +80 -80
  22. package/dist/templates/nextjs-app-router/.cursor/rules/javascript.mdc +112 -112
  23. package/dist/templates/nextjs-app-router/.cursor/rules/sitecore.mdc +174 -174
  24. package/dist/templates/nextjs-app-router/.env.container.example +27 -27
  25. package/dist/templates/nextjs-app-router/.env.remote.example +51 -51
  26. package/dist/templates/nextjs-app-router/.gitattributes +11 -11
  27. package/dist/templates/nextjs-app-router/.windsurfrules +290 -290
  28. package/dist/templates/nextjs-app-router/eslint.config.mjs +21 -29
  29. package/dist/templates/nextjs-app-router/gitignore +31 -31
  30. package/dist/templates/nextjs-app-router/package.json +54 -55
  31. package/dist/templates/nextjs-app-router/postcss.config.mjs +5 -5
  32. package/dist/templates/nextjs-app-router/sitecore.config.ts.example +40 -40
  33. package/dist/templates/nextjs-app-router/src/app/globals.css +1 -1
  34. package/dist/templates/nextjs-app-router/src/proxy.ts +11 -3
  35. package/dist/templates/nextjs-app-router/tsconfig.json +48 -48
  36. package/package.json +2 -2
@@ -1,174 +1,174 @@
1
- ---
2
- description: Sitecore development patterns for your App Router project
3
- alwaysApply: false
4
- globs:
5
- - 'src/app/**'
6
- - 'src/components/**'
7
- - 'src/lib/**'
8
- - 'sitecore.config.ts'
9
- - '**/*sitecore*'
10
- - '**/*content*'
11
- ---
12
-
13
- # Sitecore App Router Development
14
-
15
- ## Server Component Patterns
16
-
17
- Sitecore Data Fetching:
18
-
19
- - Use Server Components for Sitecore content
20
- - Fetch data directly in components when possible
21
- - Handle loading and error states appropriately
22
- - Cache responses for better performance
23
-
24
- ```typescript
25
- // Server Component example
26
- import { getLayoutData } from '@/lib/sitecore';
27
-
28
- export default async function SitecorePage({ params }: { params: { path: string[] } }) {
29
- try {
30
- const layoutData = await getLayoutData(params.path.join('/'));
31
- return <SitecoreLayout layoutData={layoutData} />;
32
- } catch (error) {
33
- return <div>Content not found</div>;
34
- }
35
- }
36
- ```
37
-
38
- ## Client Component Integration
39
-
40
- Interactive Sitecore Components:
41
-
42
- - Use 'use client' directive when needed
43
- - Keep client components focused on interactivity
44
- - Pass server-fetched data as props
45
- - Handle hydration mismatches carefully
46
-
47
- ```typescript
48
- 'use client';
49
-
50
- interface InteractiveSitecoreComponentProps {
51
- fields: {
52
- title: Field;
53
- content: Field;
54
- };
55
- }
56
-
57
- export default function InteractiveSitecoreComponent({
58
- fields,
59
- }: InteractiveSitecoreComponentProps) {
60
- // Client-side interactivity here
61
- return (
62
- <div>
63
- <Text field={fields?.title} tag="h2" />
64
- <RichText field={fields?.content} />
65
- </div>
66
- );
67
- }
68
- ```
69
-
70
- ## Component Development
71
-
72
- Sitecore Component Naming:
73
-
74
- - Use descriptive, feature-based names: `HeroWithContent`, `ProductListing`, `ContentBlockGrid`
75
- - Follow PascalCase convention
76
- - Include component type in name when helpful: `LayoutContainer`, `ContentRenderer`
77
-
78
- Field Handling:
79
-
80
- - Always validate field existence before rendering
81
- - Use helper functions for common field operations
82
- - Handle empty/null fields gracefully
83
- - Prefer Sitecore field components over manual rendering
84
-
85
- ## Routing and Data
86
-
87
- Dynamic Routes:
88
-
89
- - Use [...path] for Sitecore catch-all routes
90
- - Handle route parameters appropriately
91
- - Implement proper 404 handling
92
- - Support preview mode when needed
93
-
94
- Layout and Loading:
95
-
96
- - Create layout.tsx for shared page structure
97
- - Implement loading.tsx for better UX
98
- - Use error.tsx for error boundaries
99
- - Handle metadata and SEO properly
100
-
101
- ## Internationalization
102
-
103
- Multi-language Support:
104
-
105
- - Configure next-intl for language routing
106
- - Handle Sitecore language contexts
107
- - Implement language switching
108
- - Use proper locale-based data fetching
109
-
110
- ```typescript
111
- // Language-aware data fetching
112
- import { getTranslations } from 'next-intl/server';
113
-
114
- export default async function LocalizedPage() {
115
- const t = await getTranslations('common');
116
- // Fetch Sitecore content for current locale
117
- }
118
- ```
119
-
120
- ## Configuration
121
-
122
- Environment Setup:
123
-
124
- - Use `.env.local` for local development
125
- - Never commit API keys to version control
126
- - Use `.env.example` to document required variables
127
- - Configure Sitecore endpoints in `sitecore.config.ts`
128
-
129
- ```typescript
130
- // sitecore.config.ts
131
- import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
132
-
133
- export default defineConfig({
134
- api: {
135
- edge: {
136
- contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
137
- clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
138
- edgeUrl:
139
- process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
140
- process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
141
- 'https://edge-platform.sitecorecloud.io',
142
- },
143
- local: {
144
- apiKey: process.env.SITECORE_API_KEY || '',
145
- apiHost: process.env.SITECORE_API_HOST || '',
146
- },
147
- },
148
- defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
149
- defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
150
- editingSecret: process.env.SITECORE_EDITING_SECRET,
151
- });
152
- ```
153
-
154
- ## Performance Optimization
155
-
156
- Server-Side Rendering:
157
-
158
- - Leverage SSR for Sitecore content
159
- - Use streaming for improved perceived performance
160
- - Implement proper caching headers
161
- - Optimize bundle size with Server Components
162
-
163
- Caching Strategies:
164
-
165
- - Cache Sitecore API responses appropriately
166
- - Use Next.js caching features
167
- - Handle content updates and cache invalidation
168
- - Consider CDN caching for static content
169
-
170
- Referenced:
171
- @src/app/
172
- @src/components/
173
- @src/i18n/
174
- @sitecore.config.ts
1
+ ---
2
+ description: Sitecore development patterns for your App Router project
3
+ alwaysApply: false
4
+ globs:
5
+ - 'src/app/**'
6
+ - 'src/components/**'
7
+ - 'src/lib/**'
8
+ - 'sitecore.config.ts'
9
+ - '**/*sitecore*'
10
+ - '**/*content*'
11
+ ---
12
+
13
+ # Sitecore App Router Development
14
+
15
+ ## Server Component Patterns
16
+
17
+ Sitecore Data Fetching:
18
+
19
+ - Use Server Components for Sitecore content
20
+ - Fetch data directly in components when possible
21
+ - Handle loading and error states appropriately
22
+ - Cache responses for better performance
23
+
24
+ ```typescript
25
+ // Server Component example
26
+ import { getLayoutData } from '@/lib/sitecore';
27
+
28
+ export default async function SitecorePage({ params }: { params: { path: string[] } }) {
29
+ try {
30
+ const layoutData = await getLayoutData(params.path.join('/'));
31
+ return <SitecoreLayout layoutData={layoutData} />;
32
+ } catch (error) {
33
+ return <div>Content not found</div>;
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Client Component Integration
39
+
40
+ Interactive Sitecore Components:
41
+
42
+ - Use 'use client' directive when needed
43
+ - Keep client components focused on interactivity
44
+ - Pass server-fetched data as props
45
+ - Handle hydration mismatches carefully
46
+
47
+ ```typescript
48
+ 'use client';
49
+
50
+ interface InteractiveSitecoreComponentProps {
51
+ fields: {
52
+ title: Field;
53
+ content: Field;
54
+ };
55
+ }
56
+
57
+ export default function InteractiveSitecoreComponent({
58
+ fields,
59
+ }: InteractiveSitecoreComponentProps) {
60
+ // Client-side interactivity here
61
+ return (
62
+ <div>
63
+ <Text field={fields?.title} tag="h2" />
64
+ <RichText field={fields?.content} />
65
+ </div>
66
+ );
67
+ }
68
+ ```
69
+
70
+ ## Component Development
71
+
72
+ Sitecore Component Naming:
73
+
74
+ - Use descriptive, feature-based names: `HeroWithContent`, `ProductListing`, `ContentBlockGrid`
75
+ - Follow PascalCase convention
76
+ - Include component type in name when helpful: `LayoutContainer`, `ContentRenderer`
77
+
78
+ Field Handling:
79
+
80
+ - Always validate field existence before rendering
81
+ - Use helper functions for common field operations
82
+ - Handle empty/null fields gracefully
83
+ - Prefer Sitecore field components over manual rendering
84
+
85
+ ## Routing and Data
86
+
87
+ Dynamic Routes:
88
+
89
+ - Use [...path] for Sitecore catch-all routes
90
+ - Handle route parameters appropriately
91
+ - Implement proper 404 handling
92
+ - Support preview mode when needed
93
+
94
+ Layout and Loading:
95
+
96
+ - Create layout.tsx for shared page structure
97
+ - Implement loading.tsx for better UX
98
+ - Use error.tsx for error boundaries
99
+ - Handle metadata and SEO properly
100
+
101
+ ## Internationalization
102
+
103
+ Multi-language Support:
104
+
105
+ - Configure next-intl for language routing
106
+ - Handle Sitecore language contexts
107
+ - Implement language switching
108
+ - Use proper locale-based data fetching
109
+
110
+ ```typescript
111
+ // Language-aware data fetching
112
+ import { getTranslations } from 'next-intl/server';
113
+
114
+ export default async function LocalizedPage() {
115
+ const t = await getTranslations('common');
116
+ // Fetch Sitecore content for current locale
117
+ }
118
+ ```
119
+
120
+ ## Configuration
121
+
122
+ Environment Setup:
123
+
124
+ - Use `.env.local` for local development
125
+ - Never commit API keys to version control
126
+ - Use `.env.example` to document required variables
127
+ - Configure Sitecore endpoints in `sitecore.config.ts`
128
+
129
+ ```typescript
130
+ // sitecore.config.ts
131
+ import { defineConfig } from '@sitecore-content-sdk/nextjs/config';
132
+
133
+ export default defineConfig({
134
+ api: {
135
+ edge: {
136
+ contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
137
+ clientContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID,
138
+ edgeUrl:
139
+ process.env.NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME ||
140
+ process.env.SITECORE_EDGE_PLATFORM_HOSTNAME ||
141
+ 'https://edge-platform.sitecorecloud.io',
142
+ },
143
+ local: {
144
+ apiKey: process.env.SITECORE_API_KEY || '',
145
+ apiHost: process.env.SITECORE_API_HOST || '',
146
+ },
147
+ },
148
+ defaultSite: process.env.NEXT_PUBLIC_DEFAULT_SITE_NAME || 'default',
149
+ defaultLanguage: process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE || 'en',
150
+ editingSecret: process.env.SITECORE_EDITING_SECRET,
151
+ });
152
+ ```
153
+
154
+ ## Performance Optimization
155
+
156
+ Server-Side Rendering:
157
+
158
+ - Leverage SSR for Sitecore content
159
+ - Use streaming for improved perceived performance
160
+ - Implement proper caching headers
161
+ - Optimize bundle size with Server Components
162
+
163
+ Caching Strategies:
164
+
165
+ - Cache Sitecore API responses appropriately
166
+ - Use Next.js caching features
167
+ - Handle content updates and cache invalidation
168
+ - Consider CDN caching for static content
169
+
170
+ Referenced:
171
+ @src/app/
172
+ @src/components/
173
+ @src/i18n/
174
+ @sitecore.config.ts
@@ -1,27 +1,27 @@
1
- # This file should be copied to .env.local and modified with your environment variables to connect to your Sitecore container instance.
2
-
3
- # To secure the Sitecore editor endpoint exposed by your Next.js app
4
- # (`/api/editing/render` by default), a secret token is used. This (client-side)
5
- SITECORE_EDITING_SECRET=
6
-
7
- # Your Sitecore site name.
8
- # The value of the variable represents the default/configured site.
9
- NEXT_PUBLIC_DEFAULT_SITE_NAME=
10
-
11
- # Your default app language.
12
- NEXT_PUBLIC_DEFAULT_LANGUAGE=
13
-
14
- # Your Sitecore API key is needed to build the app.
15
- NEXT_PUBLIC_SITECORE_API_KEY=
16
-
17
- # Your Sitecore API hostname is needed to build the app.
18
- NEXT_PUBLIC_SITECORE_API_HOST=
19
-
20
- # Sitecore Content SDK npm packages utilize the debug module for debug logging.
21
- # https://www.npmjs.com/package/debug
22
- # Set the DEBUG environment variable to 'content-sdk:*' to see all logs:
23
- #DEBUG=content-sdk:*
24
- # Or be selective and show for example only layout service logs:
25
- #DEBUG=content-sdk:layout
26
- # Or everything BUT layout service logs:
27
- #DEBUG=content-sdk:*,-content-sdk:layout
1
+ # This file should be copied to .env.local and modified with your environment variables to connect to your Sitecore container instance.
2
+
3
+ # To secure the Sitecore editor endpoint exposed by your Next.js app
4
+ # (`/api/editing/render` by default), a secret token is used. This (client-side)
5
+ SITECORE_EDITING_SECRET=
6
+
7
+ # Your Sitecore site name.
8
+ # The value of the variable represents the default/configured site.
9
+ NEXT_PUBLIC_DEFAULT_SITE_NAME=
10
+
11
+ # Your default app language.
12
+ NEXT_PUBLIC_DEFAULT_LANGUAGE=
13
+
14
+ # Your Sitecore API key is needed to build the app.
15
+ NEXT_PUBLIC_SITECORE_API_KEY=
16
+
17
+ # Your Sitecore API hostname is needed to build the app.
18
+ NEXT_PUBLIC_SITECORE_API_HOST=
19
+
20
+ # Sitecore Content SDK npm packages utilize the debug module for debug logging.
21
+ # https://www.npmjs.com/package/debug
22
+ # Set the DEBUG environment variable to 'content-sdk:*' to see all logs:
23
+ #DEBUG=content-sdk:*
24
+ # Or be selective and show for example only layout service logs:
25
+ #DEBUG=content-sdk:layout
26
+ # Or everything BUT layout service logs:
27
+ #DEBUG=content-sdk:*,-content-sdk:layout
@@ -1,51 +1,51 @@
1
- # This file should be copied to .env.local and modified with your environment variables to connect to your remote Sitecore instance.
2
-
3
- # To secure the Sitecore editor endpoint exposed by your Next.js app
4
- # (`/api/editing/render` by default), a secret token is used. This (client-side)
5
- SITECORE_EDITING_SECRET=
6
-
7
- # Your Sitecore site name.
8
- # The value of the variable represents the default/configured site.
9
- NEXT_PUBLIC_DEFAULT_SITE_NAME=
10
-
11
- # Your default app language.
12
- NEXT_PUBLIC_DEFAULT_LANGUAGE=
13
-
14
- # Your unified Sitecore Edge Context Id for server-side use.
15
- # This will be used over any Sitecore Preview / Delivery Edge variables (above).
16
- SITECORE_EDGE_CONTEXT_ID=
17
-
18
- # Your Sitecore Edge Context Id for client-side use.
19
- # Will be used as a fallback if separate SITECORE_EDGE_CONTEXT_ID value is not provided
20
- NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID=
21
-
22
- # Optional: custom Sitecore Edge Platform hostname (hostname or full URL).
23
- NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME=
24
-
25
- # Optional: custom Experience Edge hostname for media URL rewriting (e.g. staging).
26
- SITECORE_EXPERIENCE_EDGE_HOSTNAME=
27
-
28
- # An optional Sitecore Personalize scope identifier.
29
- # This can be used to isolate personalization data when multiple XM Cloud Environments share a Personalize tenant.
30
- # This should match the PAGES_PERSONALIZE_SCOPE environment variable for your connected XM Cloud Environment.
31
- NEXT_PUBLIC_PERSONALIZE_SCOPE=
32
-
33
- # Timeout (ms) for Sitecore CDP requests to respond within. Default is 400.
34
- PERSONALIZE_MIDDLEWARE_CDP_TIMEOUT=
35
-
36
- # Timeout (ms) for Sitecore Experience Edge requests to respond within. Default is 400.
37
- PERSONALIZE_MIDDLEWARE_EDGE_TIMEOUT=
38
-
39
- # Sitecore Content SDK npm packages utilize the debug module for debug logging.
40
- # https://www.npmjs.com/package/debug
41
- # Set the DEBUG environment variable to 'content-sdk:*' to see all logs:
42
- #DEBUG=content-sdk:*
43
- # Or be selective and show for example only layout service logs:
44
- #DEBUG=content-sdk:layout
45
- # Or everything BUT layout service logs:
46
- #DEBUG=content-sdk:*,-content-sdk:layout
47
-
48
- # Client ID, Secret and Rendering Host Name used for Design Library functionality
49
- SITECORE_AUTH_CLIENT_ID=
50
- SITECORE_AUTH_CLIENT_SECRET=
51
- SITECORE_RENDERINGHOST_NAME=
1
+ # This file should be copied to .env.local and modified with your environment variables to connect to your remote Sitecore instance.
2
+
3
+ # To secure the Sitecore editor endpoint exposed by your Next.js app
4
+ # (`/api/editing/render` by default), a secret token is used. This (client-side)
5
+ SITECORE_EDITING_SECRET=
6
+
7
+ # Your Sitecore site name.
8
+ # The value of the variable represents the default/configured site.
9
+ NEXT_PUBLIC_DEFAULT_SITE_NAME=
10
+
11
+ # Your default app language.
12
+ NEXT_PUBLIC_DEFAULT_LANGUAGE=
13
+
14
+ # Your unified Sitecore Edge Context Id for server-side use.
15
+ # This will be used over any Sitecore Preview / Delivery Edge variables (above).
16
+ SITECORE_EDGE_CONTEXT_ID=
17
+
18
+ # Your Sitecore Edge Context Id for client-side use.
19
+ # Will be used as a fallback if separate SITECORE_EDGE_CONTEXT_ID value is not provided
20
+ NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID=
21
+
22
+ # Optional: custom Sitecore Edge Platform hostname (hostname or full URL).
23
+ NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME=
24
+
25
+ # Optional: custom Experience Edge hostname for media URL rewriting (e.g. staging).
26
+ SITECORE_EXPERIENCE_EDGE_HOSTNAME=
27
+
28
+ # An optional Sitecore Personalize scope identifier.
29
+ # This can be used to isolate personalization data when multiple XM Cloud Environments share a Personalize tenant.
30
+ # This should match the PAGES_PERSONALIZE_SCOPE environment variable for your connected XM Cloud Environment.
31
+ NEXT_PUBLIC_PERSONALIZE_SCOPE=
32
+
33
+ # Timeout (ms) for Sitecore CDP requests to respond within. Default is 400.
34
+ PERSONALIZE_MIDDLEWARE_CDP_TIMEOUT=
35
+
36
+ # Timeout (ms) for Sitecore Experience Edge requests to respond within. Default is 400.
37
+ PERSONALIZE_MIDDLEWARE_EDGE_TIMEOUT=
38
+
39
+ # Sitecore Content SDK npm packages utilize the debug module for debug logging.
40
+ # https://www.npmjs.com/package/debug
41
+ # Set the DEBUG environment variable to 'content-sdk:*' to see all logs:
42
+ #DEBUG=content-sdk:*
43
+ # Or be selective and show for example only layout service logs:
44
+ #DEBUG=content-sdk:layout
45
+ # Or everything BUT layout service logs:
46
+ #DEBUG=content-sdk:*,-content-sdk:layout
47
+
48
+ # Client ID, Secret and Rendering Host Name used for Design Library functionality
49
+ SITECORE_AUTH_CLIENT_ID=
50
+ SITECORE_AUTH_CLIENT_SECRET=
51
+ SITECORE_RENDERINGHOST_NAME=
@@ -1,11 +1,11 @@
1
- # Line endings for this repository
2
- # See: https://help.github.com/en/articles/configuring-git-to-handle-line-endings
3
- # This should line up with the expectations from .eslintrc
4
-
5
- # Set the default behavior, in case people don't have core.autocrlf set.
6
- * text=crlf
7
-
8
- # Declare files that will always have CRLF line endings on checkout.
9
- *.ts text eol=crlf
10
- *.tsx text eol=crlf
11
- *.js text eol=crlf
1
+ # Line endings for this repository
2
+ # See: https://help.github.com/en/articles/configuring-git-to-handle-line-endings
3
+ # This should line up with the expectations from .eslintrc
4
+
5
+ # Set the default behavior, in case people don't have core.autocrlf set.
6
+ * text=crlf
7
+
8
+ # Declare files that will always have CRLF line endings on checkout.
9
+ *.ts text eol=crlf
10
+ *.tsx text eol=crlf
11
+ *.js text eol=crlf