What is the intended purpose of the "templates" folder in the Next.js Starter Storefront module structure? #567
Replies: 1 comment
-
|
1. The Role of the templates Folder The convention is to separate Routing/Orchestration from UI Layout. 2. Data Fetching: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I noticed that the Next.js Starter Storefront uses a templates folder inside each module (e.g., src/modules/account/templates/Copy to Clipboard, src/modules/order/templates/Copy to Clipboard).
At first, I assumed this folder was meant for SSR (server-side rendered) components, but I found that some template components use client-side hooks like useState and useActionState, meaning they are CSR components as well.
Could you clarify the intended design pattern or convention behind the templates folder? Is it:
A separation of concerns pattern (page fetches data → template handles UI)?
Related to the Template Method design pattern?
Simply a naming convention with no strict SSR/CSR distinction?
Any clarification on the intended architecture would be greatly appreciated!
What is the recommended pattern for data fetching in page.tsx vs template components in the Next.js Starter?
I've noticed two different data fetching patterns used in the Next.js Starter Storefront:
Pattern A: page.tsx fetches data and passes it as props to the template
Code
Pattern B: page.tsx only handles metadata, and the template component handles its own data fetching
Both patterns seem to be used across the codebase. Could you clarify:
Is there a recommended or preferred pattern?
Are there specific use cases where one is preferred over the other (e.g., SEO, performance, complexity)?
Is there a convention or architectural guideline behind this decision?
Any clarification on the intended architecture would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions